How to use the object-path-immutable function in object-path-immutable

To help you get started, we’ve selected a few object-path-immutable 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 redux-json-api / redux-json-api / src / jsonapi.js View on Github external
[API_SET_HEADER]: (state, { payload: header }) => {
    const newState = imm(state);
    Object.keys(header).forEach(key => {
      newState.set(['endpoint', 'headers', key], header[key]);
    });

    return newState.value();
  },
github redux-json-api / redux-json-api / src / jsonapi.js View on Github external
[API_WILL_CREATE]: (state) => {
    return imm(state).set(['isCreating'], state.isCreating + 1).value();
  },
github coverhound / active-redux / src / api / utils / index.js View on Github external
export const mergeResources = (state, { data, included = [] }) => {
  const newState = imm(state);

  resourcesArray(data).concat(included).forEach((dataObj) => {
    const { id, type } = dataObj;
    newState.set(['resources', type, String(id)], dataObj);
    createReverseRelationships(state, newState, dataObj);
  });

  return newState.value();
};
github prisma / photonjs / packages / photon-generate / archive / benchmark-immutable-set.ts View on Github external
.add('object-path-immutable', () => {
    immutableO(obj).set('createUser.data.post.create.title', 'String')
  })
  .add('immutable', () => {
github redux-json-api / redux-json-api / src / jsonapi.js View on Github external
[API_READ]: (state, { payload }) => {
    const resources = (
      Array.isArray(payload.data)
        ? payload.data
        : [payload.data]
    ).concat(payload.included || []);

    const newState = updateOrInsertResourcesIntoState(state, resources);
    const finalState = addLinksToState(newState, payload.links, payload.options);

    return imm(finalState)
      .set('isReading', state.isReading - 1)
      .value();
  },

object-path-immutable

Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis