How to use the immutable.Set.of 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 alexisvincent / systemjs-hmr / lib / util.ts View on Github external
export const findEntries = (context: Context) => {
    const { trace } = context
    let entries = Set() as Set
    let modulesToExplore = Set.of(...trace.keys())

    while (modulesToExplore.size > 0) {
        // pick a node and add it to entries
        const node = modulesToExplore.first()
        modulesToExplore = modulesToExplore.remove(node)
        entries = entries.add(node)

        const removeDepsOf = (dep) => {
            modulesToExplore = modulesToExplore.remove(dep)

            if (trace.has(dep))
                getDependencies(context, dep)
                    .forEach(depToRemove => {
                        if (entries.has(depToRemove)) entries = entries.remove(depToRemove)
                        else if (modulesToExplore.has(depToRemove)) removeDepsOf(depToRemove)
                    })
github duckpunch / godash / test / test_board.js View on Github external
it('finds a group of 2', function() {
        const coordinate = new Coordinate(2, 2);
        const board = new Board(5,
            new Coordinate(2, 2), BLACK,
            new Coordinate(2, 1), BLACK,
        );

        assert.ok(
            group(board, coordinate).equals(
                Set.of(
                    new Coordinate(2, 2),
                    new Coordinate(2, 1),
                )
            )
        );
    });
github optimizely / nuclear-js / tests / reactor-fns-tests.js View on Github external
it('should update dirtyStores', () => {
        const result = nextReactorState.get('dirtyStores')
        const expected = Set.of('store2')
        expect(is(result, expected)).toBe(true)
      })
github probmods / webppl / src / analysis / analyze.js View on Github external
v = store.get(e.name, null) || global.get(e.name, null);
      }
      else {
        v = environment.get(e.name, null);
      }

      if (v) {
        return v;
      }
      else {
        console.log(e);
        throw new Error('not found in environment');
      }
    case Syntax.Literal:
      return new AValue({
        values: Set.of(e.value),
        states: dependence
      });
    default:
      console.log(e);
      throw new Error('unimplemented Au');
  }
}
github probmods / webppl / src / analysis / main.js View on Github external
}
    case Syntax.CallExpression:
      if (types.MemberExpression.check(expr.callee) &&
          ! expr.callee.computed &&
          expr.callee.property.name === 'concat') {
        console.log(Au(store, environment, expr.callee.object));
        console.log(Au(store, environment, expr.callee.object));
        throw 23;
      }
      else {
        console.log(expr);
        console.log(require('escodegen').generate(expr));
        throw 12;
      }
    case Syntax.FunctionExpression:
      return Set.of(expr);
    case Syntax.Identifier:
      var value = environment.get(expr.name, false) || store.get(expr.name, false);

      if (! value) {
        if (primitives.hasOwnProperty(expr.name)) {
          value = Set.of(primitives[expr.name]);
        }
        else {
          console.log(store);
          console.log(environment);
          throw new Error('Au: unbound variable: ' + expr.name);
        }
      }

      return value;
    case Syntax.Literal:
github duckpunch / godash / src / board.js View on Github external
export function adjacentCoordinates(board, coordinate) {
    const {x, y} = coordinate;
    const validRange = n => inRange(n, board.dimensions);

    return Set.of(
        new Coordinate(x, y + 1),
        new Coordinate(x, y - 1),
        new Coordinate(x + 1, y),
        new Coordinate(x - 1, y),
    ).filter(c => c.every(validRange));
}
github probmods / webppl / src / analysis / main.js View on Github external
uniformERP: function uniform(a, b) {
    return Set.of(new Num({}));
  }
}
github RSNara / reddit-client / src / reducers / subreddits.js View on Github external
[SUBREDDITS.SAVE_THREADS]: (state, { payload }) => {
    const { subreddit, threads, filter } = payload;
    const filterSet = filter ? Set.of(filter) : Set();
    return state.updateIn(
      ['threads', subreddit], indexedUpsert(fromJS(threads).map(
        (thread) => thread.set('filters', filterSet)
      ))
    );
  },
github holmari / gerritstats / GerritStats / src / main / frontend / common / model / SelectedUsers.jsx View on Github external
static fromLocalStorage(primaryStorageKey, ids) {
        const key = SelectedUsers._getStorageKey(primaryStorageKey);
        var users = JSON.parse(localStorage.getItem(key));
        if (users === null) {
            users = SelectedUsers._selectAllUsers(ids);
        } else {
            users = Set.of(...users);
        }
        return new SelectedUsers(primaryStorageKey, ids, users);
    }
github editorsnotes / edit-with-lov / src / lovutils.js View on Github external
} = N3.Util
    , request = require('request')
    , {Map, List, Set, fromJS} = require('immutable')
    , {JSONLDNode, JSONLDValue} = require('immutable-jsonld')
    , ns = require('rdf-ns')

const LOV_V2 = 'https://lov.okfn.org/dataset/lov/api/v2'
const VOCAB_LIST = `${LOV_V2}/vocabulary/list`
const VOCAB_INFO = `${LOV_V2}/vocabulary/info?vocab=`

const owl = ns('http://www.w3.org/2002/07/owl#')
    , rdf = ns('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
    , rdfs = ns('http://www.w3.org/2000/01/rdf-schema#')
    , skos = ns('http://www.w3.org/2004/02/skos/core#')

const CLASS_TYPES = Set.of(
  owl('Class'),
  rdfs('Class'),
  rdfs('Datatype')
)

const PROPERTY_TYPES = Set.of(
  owl('ObjectProperty'),
  owl('DatatypeProperty'),
  owl('AnnotationProperty'),
  owl('OntologyProperty'),
  rdf('Property')
)

const rollup = predicates => (results, triple) => (
  predicates.has(triple.predicate)
    ? results.update(triple.subject, JSONLDNode({'@id': triple.subject}),