How to use array-differ - 5 common examples

To help you get started, we’ve selected a few array-differ examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / pageres / lib / index.js View on Github external
await Promise.all(this.src().map(src => { // eslint-disable-line array-callback-return
			const options = {...this.options, ...src.options};
			const sizes = arrayUniq(src.sizes.filter(/./.test, /^\d{2,4}x\d{2,4}$/i));
			const keywords = arrayDiffer(src.sizes, sizes);

			if (!src.url) {
				throw new Error('URL required');
			}

			this.urls.push(src.url);

			if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
				return this.resolution(src.url, options);
			}

			if (keywords.length > 0) {
				return this.viewport({url: src.url, sizes, keywords}, options);
			}

			for (const size of sizes) {
github deltachat / deltachat-desktop / src / renderer / components / dialogs / EditGroup.js View on Github external
const updateGroup = async () => {
    const remove = differ(initialGroupMembers, groupMembers)
    const add = differ(groupMembers, initialGroupMembers)
    await callDcMethodAsync('chat.modifyGroup', [groupId, groupName, groupImage, remove, add])
  }
  const onUpdateGroup = async () => {
github vkbansal / illuminate-js / src / utils / lang.js View on Github external
export function extend(source, ext) {
    let { _order: srcOrder } = source,
        { _order: extOrder, ...props } = ext,
        extKeys = Object.keys(props);

    let newTokens = diff(extKeys, srcOrder);

    let def = clone(source);

    return extendShallow(def, ext, {
        _order: srcOrder.concat(newTokens)
    });
}
github vkbansal / illuminate-js / src / utils / lang.js View on Github external
export function insertBefore(source, before, insert) {
    if (!isObj(source) || !source.hasOwnProperty("_order") || !Array.isArray(source._order)) {
        throw new Error("Source does not have required property '_order' as an array.");
    }

    if (!isObj(insert) || !insert.hasOwnProperty("_order") || !Array.isArray(insert._order)) {
        throw new Error("insert does not have required property '_order' as an array");
    }

    source._order = diff(source._order, Object.keys(insert));

    let index = source._order.indexOf(before);

    source._order.splice(index, 0, ...insert._order);

    delete insert._order;

    return extendShallow(source, insert);
}
github deltachat / deltachat-desktop / src / renderer / components / dialogs / EditGroup.js View on Github external
const updateGroup = async () => {
    const remove = differ(initialGroupMembers, groupMembers)
    const add = differ(groupMembers, initialGroupMembers)
    await callDcMethodAsync('chat.modifyGroup', [groupId, groupName, groupImage, remove, add])
  }
  const onUpdateGroup = async () => {

array-differ

Create an array with values that are present in the first input array but not additional ones

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular array-differ functions