How to use copy-anything - 7 common examples

To help you get started, we’ve selected a few copy-anything 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 mesqueeb / vuex-easy-firestore / dist / index.esm.js View on Github external
RESET_VUEX_EASY_FIRESTORE_STATE: function (state) {
            // unsubscribe all DBChannel listeners:
            Object.keys(state._sync.unsubscribe).forEach(function (unsubscribe) {
                if (isFunction(unsubscribe))
                    unsubscribe();
            });
            var self = this;
            var _sync = pluginState()._sync;
            var newState = merge(copy(userState), { _sync: _sync });
            var statePropName = state._conf.statePropName;
            var docContainer = (statePropName)
                ? state[statePropName]
                : state;
            Object.keys(newState).forEach(function (key) {
                self._vm.$set(state, key, newState[key]);
            });
            Object.keys(docContainer).forEach(function (key) {
                if (Object.keys(newState).includes(key))
                    return;
                self._vm.$delete(docContainer, key);
            });
        },
        resetSyncStack: function (state) {
github mesqueeb / vuex-easy-firestore / dist / index.esm.js View on Github external
function iniModule (userConfig, FirebaseDependency) {
    // prepare state._conf
    var conf = copy(merge({ state: {}, mutations: {}, actions: {}, getters: {} }, defaultConfig, userConfig));
    if (!errorCheck(conf))
        return;
    var userState = conf.state;
    var userMutations = conf.mutations;
    var userActions = conf.actions;
    var userGetters = conf.getters;
    delete conf.state;
    delete conf.mutations;
    delete conf.actions;
    delete conf.getters;
    // prepare rest of state
    var docContainer = {};
    if (conf.statePropName)
        docContainer[conf.statePropName] = {};
    var restOfState = merge(userState, docContainer);
    // if 'doc' mode, set merge initial state onto default values
github mesqueeb / vuex-easy-firestore / src / module / index.ts View on Github external
const userActions = conf.actions
  const userGetters = conf.getters
  delete conf.state
  delete conf.mutations
  delete conf.actions
  delete conf.getters
  // prepare rest of state
  const docContainer = {}
  if (conf.statePropName) docContainer[conf.statePropName] = {}
  const restOfState = merge(userState, docContainer)
  // if 'doc' mode, set merge initial state onto default values
  if (conf.firestoreRefType === 'doc') {
    const defaultValsInState = (conf.statePropName)
      ? restOfState[conf.statePropName]
      : restOfState
    conf.sync.defaultValues = copy(merge(
      defaultValsInState,
      conf.sync.defaultValues
    ))
  }
  return {
    namespaced: true,
    state: merge(pluginState(), restOfState, {_conf: conf}),
    mutations: merge(userMutations, pluginMutations(merge(userState, {_conf: conf}))),
    actions: merge(userActions, pluginActions(FirebaseDependency)),
    getters: merge(userGetters, pluginGetters(FirebaseDependency))
  }
}
github mesqueeb / vuex-easy-firestore / dist / index.esm.js View on Github external
var userGetters = conf.getters;
    delete conf.state;
    delete conf.mutations;
    delete conf.actions;
    delete conf.getters;
    // prepare rest of state
    var docContainer = {};
    if (conf.statePropName)
        docContainer[conf.statePropName] = {};
    var restOfState = merge(userState, docContainer);
    // if 'doc' mode, set merge initial state onto default values
    if (conf.firestoreRefType === 'doc') {
        var defaultValsInState = (conf.statePropName)
            ? restOfState[conf.statePropName]
            : restOfState;
        conf.sync.defaultValues = copy(merge(defaultValsInState, conf.sync.defaultValues));
    }
    return {
        namespaced: true,
        state: merge(pluginState(), restOfState, { _conf: conf }),
        mutations: merge(userMutations, pluginMutations(merge(userState, { _conf: conf }))),
        actions: merge(userActions, pluginActions(FirebaseDependency)),
        getters: merge(userGetters, pluginGetters(FirebaseDependency))
    };
}
github mesqueeb / vuex-easy-firestore / src / module / actions.ts View on Github external
function firestoreUpdateFn (_val) {
        return dispatch('patchDoc', {id, doc: copy(_val)})
      }
      // define the store update
github mesqueeb / vuex-easy-firestore / dist / index.esm.js View on Github external
function firestoreUpdateFn(_val) {
                return dispatch('patchDoc', { id: id, doc: copy(_val) });
            }
            // define the store update
github mesqueeb / vuex-easy-firestore / src / module / mutations.ts View on Github external
RESET_VUEX_EASY_FIRESTORE_STATE (state) {
      // unsubscribe all DBChannel listeners:
      Object.keys(state._sync.unsubscribe).forEach(unsubscribe => {
        if (isFunction(unsubscribe)) unsubscribe()
      })
      const self = this
      const { _sync } = getStateWithSync()
      const newState = merge(copy(userState), {_sync})
      const { statePropName } = state._conf
      const docContainer = (statePropName)
        ? state[statePropName]
        : state
      Object.keys(newState).forEach(key => {
        self._vm.$set(state, key, newState[key])
      })
      Object.keys(docContainer).forEach(key => {
        if (Object.keys(newState).includes(key)) return
        self._vm.$delete(docContainer, key)
      })
    },
    resetSyncStack (state) {

copy-anything

An optimised way to copy'ing an object. A small and simple integration

MIT
Latest version published 6 months ago

Package Health Score

70 / 100
Full package analysis

Popular copy-anything functions