How to use shallow-copy - 5 common examples

To help you get started, we’ve selected a few shallow-copy 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 formio / formio.js / src / Formio.js View on Github external
// Cache the response.
        if (!Formio.ignoreCache && (method === 'GET')) {
          Formio.cache[cacheKey] = _cloneDeep(result);
        }

        let resultCopy = {};

        // Shallow copy result so modifications don't end up in cache
        if (Array.isArray(result)) {
          resultCopy = result.map(copy);
          resultCopy.skip = result.skip;
          resultCopy.limit = result.limit;
          resultCopy.serverCount = result.serverCount;
        }
        else {
          resultCopy = copy(result);
        }

        return resultCopy;
      })
      .catch((err) => {
github hughsk / autocomplete-webgl / provider-methods.js View on Github external
return matches.map(method => {
      const name = method.name

      return copy(this.methodCache[name] = (
        this.methodCache[name] || this.getMethodSuggestion(method)
      ))
    })
  }
github bigfishjs / parva / src / index.js View on Github external
function del(state, prop) {
  const obj = copy(state.obj);
  delete obj[prop];
  state.obj = obj;
  if (state.parent) {
    update(state.parent, state.key, obj);
  }
}
github bigfishjs / parva / src / index.js View on Github external
function update(state, prop, value) {
  const obj = copy(state.obj);
  obj[prop] = value;
  state.obj = obj;
  if (state.parent) {
    update(state.parent, state.key, obj);
  }
}
github bigfishjs / parva / src / proxy.js View on Github external
function update(state, prop, value) {
  const obj = copy(state.obj);
  obj[prop] = value;
  state.obj = obj;
  if (state.parent) {
    update(state.parent, state.key, obj);
  }
}

shallow-copy

make a shallow copy of an object or array

MIT
Latest version published 11 years ago

Package Health Score

59 / 100
Full package analysis

Popular shallow-copy functions