How to use the immutable.isImmutable function in immutable

To help you get started, we’ve selected a few 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 RealmTeam / react-redux-reliever / src / utils / merger.js View on Github external
export default function merger(a, b) {
  // Overwrite handling OVERWRITE
  if (b && ((isPlainObject(b) && b[OVERWRITE]) || (isImmutable(b) && b.get(OVERWRITE)))) {
    if (isImmutable(b)) b = b.delete(OVERWRITE)
    else delete b[OVERWRITE]
    return b
  }

  // Deletion handling DEL
  if (a && (Map.isMap(a) || isPlainObject(a)) && b && (Map.isMap(b) || isPlainObject(b))) {
    (isImmutable(b) ? b.entrySeq() : Object.entries(b)).forEach(([k, v]) => {
      if (v === DEL) {
        if (isImmutable(b)) b = b.delete(k)
        else delete b[k]
        if (isImmutable(a)) a = a.delete(k)
        else delete a[k]
      }
    })
  }
github kalmhq / kalm / frontend / src / utils / tableSearch.ts View on Github external
export const customSearchForImmutable = (
  filter: string,
  rowData: RowDataType,
  columnDef: Column,
): boolean => {
  // according to https://github.com/mbrn/material-table/blob/ac369e3ce292152a84732af8dfd31badce1e40d6/src/utils/data-manager.js#L624
  if (columnDef.field && rowData.get) {
    const fieldValue = rowData.get(columnDef.field as any);
    if (typeof fieldValue === "string" || typeof fieldValue === "number" || typeof fieldValue === "boolean") {
      return `${fieldValue}`.toUpperCase().includes(filter.toUpperCase());
    } else if (isImmutable(fieldValue)) {
      return JSON.stringify(fieldValue.toJS()).toUpperCase().includes(filter.toUpperCase());
    }
  }
  return false;
};
github grommet / jsx-to-string / src / index.js View on Github external
function serializeItem (item, options, delimit=true) {
  let result;

  if (isImmutable(item)) {
    result = serializeItem(item.toJS(), options, delimit);
  } else if (typeof item === 'string') {
    result = delimit ? `'${item}'` : item;
  } else if (typeof item === 'number' || typeof item === 'boolean') {
    result = `${item}`;
  } else if (Array.isArray(item)) {
    var indentation = new Array(options.spacing + 1).join(' ');
    const delimiter = delimit ? ', ' : `\n${indentation}`;
    const items = item.map(i => serializeItem(i, options)).join(delimiter);
    result = delimit ? `[${items}]` : `${items}` ;
  } else if (isValidElement(item)) {
    result = jsxToString(item, options);
  } else if (typeof item === 'object') {
    result = stringify(stringifyObject(item, options));
    // remove string quotes from embeded JSX values
    result = result.replace(_JSX_REGEXP, function (match) {
github RealmTeam / react-redux-reliever / src / utils / merger.js View on Github external
export default function merger(a, b) {
  // Overwrite handling OVERWRITE
  if (b && ((isPlainObject(b) && b[OVERWRITE]) || (isImmutable(b) && b.get(OVERWRITE)))) {
    if (isImmutable(b)) b = b.delete(OVERWRITE)
    else delete b[OVERWRITE]
    return b
  }

  // Deletion handling DEL
  if (a && (Map.isMap(a) || isPlainObject(a)) && b && (Map.isMap(b) || isPlainObject(b))) {
    (isImmutable(b) ? b.entrySeq() : Object.entries(b)).forEach(([k, v]) => {
      if (v === DEL) {
        if (isImmutable(b)) b = b.delete(k)
        else delete b[k]
        if (isImmutable(a)) a = a.delete(k)
        else delete a[k]
      }
    })
  }

  // Regular merge
  if (a && a.mergeWith && !List.isList(a) && b !== null && (Map.isMap(b) || isPlainObject(b))) {
    return a.mergeWith(merger, b)
  }
  return b
}
github nteract / nteract / packages / display-area / src / output.tsx View on Github external
render() {
    let output = this.props.output;
    let models = this.props.models;

    // TODO: Incorporate the new output record types into both commutable and the react components that use them
    if (isImmutable(output)) {
      output = output.toJS();
    }
    if (isImmutable(models)) {
      models = models.toJS();
    }

    const outputType = output.output_type;

    switch (outputType) {
      case "execute_result":
      // We can defer to display data here, the cell number will be handled
      // separately. For reference, it is output.execution_count
      // The execution_count belongs in the component above if
      // this is a code cell

      // falls through
      case "display_data": {
        const bundle = output.data;
        const metadata = output.metadata;
github Canner / canner / src / app / utils / transformData.js View on Github external
const isTransform = function(data: mixed): boolean {
  return isString(data) ||
    isBoolean(data) ||
    isNumber(data) ||
    Immutable.isImmutable(data);
};
github socialtables / openfpc / src / model / scene.js View on Github external
mergeImmediate (changes) {
    let mergedEntities = this.get("entities").merge(changes);
    if (changes) {
      const imChanges = isImmutable(changes) ? changes : new Map(changes);
      const boundariesWithUpdates = this.getLinkedBoundaries(imChanges)
      .merge(imChanges.filter(e => e.get("type") === "boundary"));
      const objectUpdates = this.getLinkedObjects(boundariesWithUpdates)
      .filter(o => !imChanges.get(o.get("id")))
      .map(o => o.maintainAttachment(mergedEntities));
      mergedEntities = mergedEntities.merge(objectUpdates);
    }
    return this.merge({
      selection: this.get("selection").filter(e => mergedEntities.get(e)),
      entities: mergedEntities
    });
  }
github RealmTeam / react-redux-reliever / src / utils / merger.js View on Github external
(isImmutable(b) ? b.entrySeq() : Object.entries(b)).forEach(([k, v]) => {
      if (v === DEL) {
        if (isImmutable(b)) b = b.delete(k)
        else delete b[k]
        if (isImmutable(a)) a = a.delete(k)
        else delete a[k]
      }
    })
  }
github kangarang / tcr-ui / src / store.js View on Github external
      stateTransformer: state => (isImmutable(state) ? state.toJS() : state),
      collapsed: (getState, action, logEntry) => !logEntry.error,
github walnutdust / perusal / es / spec / util / addToSpecs.js View on Github external
export function addToSpecs(object, key, value) {
  if (isImmutable(object) || object.isExtendable) {
    if (!object.specs) {
      object.specs = {};
    }

    object.specs[key] = value;
  }
}