How to use the updeep.omit function in updeep

To help you get started, we’ve selected a few updeep 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 substantial / updeep / types / tests.ts View on Github external
u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github experimentalDataAesthetics / play-splom / app / reducers / mapping.js View on Github external
export function mapXYtoParam(state, action) {
  const payload = action.payload;
  // toggle: if already mapped to this then disconnect it
  if (_.get(state, `xy.${payload.xy}.params.${payload.param}`)) {
    return u(
      {
        mode: 'xy',
        xy: {
          [payload.xy]: {
            // updeep: filter this param out of params
            params: u.omit(payload.param)
          }
        }
      },
      state
    );
  }

  // connect it
  return u(
    {
      mode: 'xy',
      xy: {
        [payload.xy]: {
          params: {
            [payload.param]: true
          }
github kresusapp / kresus / client / store / banks.js View on Github external
function removeAccess(state, accessId) {
    assert(
        typeof accessId === 'number',
        'The second parameter of removeAccess should be a number id'
    );

    // First remove all the accounts attached to the access.
    let newState = state;
    for (let accountId of accountIdsByAccessId(state, accessId)) {
        newState = removeAccount(newState, accountId);
    }

    // Then remove access (should have been done by removeAccount).
    newState = updateAccessesMap(newState, u.omit(accessId));
    newState = u.updateIn('accessIds', u.reject(id => id === accessId), newState);

    // Sort again accesses in case the default account has been deleted.
    return sortAccesses(newState);
}
github kresusapp / kresus / client / store / banks.js View on Github external
// Reset the defaultAccountId if we just deleted it.
    if (getDefaultAccountId(newState) === accountId) {
        newState = u({ defaultAccountId: DefaultSettings.get('default-account-id') }, newState);
    }

    // Reset the current account id if we just deleted it.
    if (getCurrentAccountId(newState) === accountId) {
        newState = setCurrentAccessAndAccount(newState);
    }

    // Remove alerts attached to the account.
    newState = u.updateIn('alerts', u.reject(alert => alert.accountId === accountId), newState);

    // Finally, remove the account from the accounts map.
    return updateAccountsMap(newState, u.omit(accountId));
}
github Venryx / DebateMap / node_modules / react-redux-firebase / dist / reducer.js View on Github external
obj.deleteIn = function(pathNodes) {
		/*var deepObj = this;
		// tunnel down to the object holding the path-specified prop
		for (var i in pathNodes.slice(0, -1)) {
			var pathNode = pathNodes.slice(0, -1)[i];
			if (deepObj == null) break;
			deepObj = deepObj[pathNode];
		}
		delete deepObj[pathNodes.slice(-1)[0]];
		return this;*/
		//return u.updateIn(pathNodes.join("."), undefined, this);
		return u.updateIn(pathNodes.slice(0, -1).join("."), u.omit(pathNodes.slice(-1)[0]), this);
	};
}
github Venryx / DebateMap / Source / Frame / Database / DatabaseHelpers.ts View on Github external
export function ApplyDBUpdates_Local(dbData: FirebaseData, dbUpdates: Object) {
	let result = dbData;
	for (let {name: path, value} of dbUpdates.Props()) {
		if (value != null) {
			result = u.updateIn(path.replace(/\//g, "."), u.constant(value), result);
		} else {
			result = u.updateIn(path.split("/").slice(0, -1).join("."), u.omit(path.split("/").slice(-1)), result);
		}
	}
	return result;
}
github d6u / redux-chat / js / reducers / messages.js View on Github external
state);
    }

    case ActionTypes.CREATE_MESSAGE: {
      return {
        ...state,
        [action.message.id]: action.message
      };
    }

    case ActionTypes.RECEIVE_RAW_CREATED_MESSAGE: {
      let message = ChatMessageUtils.convertRawMessage(action.rawMessage);
      message.isRead = true;
      return compose(
        u({[message.id]: message}),
        u(u.omit(action.tempMessageID))
      )(state);
    }

    case ActionTypes.RECEIVE_RAW_MESSAGES: {
      let lastThreadID = last(action.rawMessages).threadID;
      let messages = indexBy(action.rawMessages, 'id');
      let formatMessage = u.map(message => u({
        isRead: message.threadID === lastThreadID,
        date: new Date(message.timestamp)
      }, message));
      let updated = u(formatMessage, messages);
      return {...state, ...updated};
    }

    default:
      return state;

updeep

Easily update nested frozen objects and arrays in a declarative and immutable manner.

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis