immutable#Iterable JavaScript Examples

The following examples show how to use immutable#Iterable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From the-eye-knows-the-garbage with MIT License 6 votes vote down vote up
structure = {
  fromJS: function fromJS(jsValue) {
    return _fromJS(jsValue, function (key, value) {
      return Iterable.isIndexed(value) ? value.toList() : value.toMap();
    });
  },
  getIn: getIn,
  merge: function merge(state, payload) {
    return state.merge(payload);
  },
  toJS: function toJS(value) {
    return Iterable.isIterable(value) ? value.toJS() : value;
  }
}
Example #2
Source File: deepEqual.js    From Lynx with MIT License 6 votes vote down vote up
customizer = function customizer(obj, other) {
  if (obj === other) return true;
  if (!obj && !other) {
    var objIsEmpty = obj === null || obj === undefined || obj === '';
    var otherIsEmpty = other === null || other === undefined || other === '';
    return objIsEmpty === otherIsEmpty;
  }

  if (Iterable.isIterable(obj) && Iterable.isIterable(other)) {
    return obj.count() === other.count() && obj.every(function (value, key) {
      return other.has(key) && _isEqualWith(value, other.get(key), customizer);
    });
  }

  return void 0;
}
Example #3
Source File: index.js    From Lynx with MIT License 6 votes vote down vote up
structure = {
  allowsArrayErrors: false,
  empty: Map(),
  emptyList: emptyList,
  getIn: function getIn(state, field) {
    return Iterable.isIterable(state) ? state.getIn(_toPath(field)) : plainGetIn(state, field);
  },
  setIn: setIn,
  deepEqual: deepEqual,
  deleteIn: function deleteIn(state, field) {
    return state.deleteIn(_toPath(field));
  },
  forEach: function forEach(items, callback) {
    items.forEach(callback);
  },
  fromJS: function fromJS(jsValue) {
    return _fromJS(jsValue, function (key, value) {
      return Iterable.isIndexed(value) ? value.toList() : value.toMap();
    });
  },
  keys: keys,
  size: function size(list) {
    return list ? list.size : 0;
  },
  some: function some(items, callback) {
    return items.some(callback);
  },
  splice: splice,
  toJS: function toJS(value) {
    return Iterable.isIterable(value) ? value.toJS() : value;
  }
}
Example #4
Source File: keys.js    From Lynx with MIT License 6 votes vote down vote up
keys = function keys(value) {
  if (List.isList(value)) {
    return value.map(function (i) {
      return i.name;
    });
  }

  if (Iterable.isIterable(value)) {
    return value.keySeq();
  }

  return value ? List(plainKeys(value)) : empty;
}
Example #5
Source File: getIn.js    From the-eye-knows-the-garbage with MIT License 5 votes vote down vote up
getIn = function getIn(state, path) {
  return Iterable.isIterable(state) ? state.getIn(path) : plainGetIn(state, path);
}