Esempio n. 1
0
function tweets(state = {
  isFetching: false,
  didInvalidate: false,
  tweets: Iterable(),
  order: 'created_at',
  sort: 'asc',
  search: ' '
}, action) {
  switch (action.type) {
    case INVALIDATE_USER:
      return Object.assign({}, state, {
        didInvalidate: true
      })
    case REQUEST_POSTS:
      return Object.assign({}, state, {
        isFetching: true,
        didInvalidate: false,
      })
    case RECEIVE_POSTS:
      return Object.assign({}, state, {
        isFetching: false,
        didInvalidate: false,
        tweets: Iterable(action.tweets),
        lastUpdated: action.receivedAt
      })
    case SELECT_ORDER:
      return Object.assign({}, state, {
        isFetching: false,
        didInvalidate: false,
        tweets: Iterable(action.tweets).sortBy(tweet => tweet[action.order]),
        lastUpdated: action.receivedAt,
        order: action.order
      })
    case SELECT_SORT:
      return Object.assign({}, state, {
        isFetching: false,
        didInvalidate: false,
        tweets: Iterable(action.tweets).reverse(),
        lastUpdated: action.receivedAt,
        sort: action.sort
      })
    case SELECT_FILTER:
      return Object.assign({}, state, {
        isFetching: false,
        didInvalidate: false,
        tweets: Iterable(action.tweets).filter(tweet => tweet.text.indexOf(action.search) > -1),
        lastUpdated: action.receivedAt,
        search: action.search
      })
    default:
      return state
  }
}
Esempio n. 2
0
 handleSocket(msgBody, state => {
   assert.equal(state.who.size, whoReply.data.listing.length)
   assert(Immutable.Iterable(whoReply.data.listing).every(user => {
     const whoEntry = state.who.get(user.session_id)
     return !!whoEntry && whoEntry.get('present') && whoEntry.isSuperset(Immutable.fromJS(user))
   }))
   done()
 })
	it('adds require for specified identifiers.', () => {
		// Given
		const identifiersToRequire = new Map([
			[Iterable(['otherGlobal']), 'otherglobal'],
			[Iterable(['emitr']), 'emitr'],
			[Iterable(['globalLibrary']), 'globallibrary'],
			[Iterable(['aLibrary', '()', 'plugin']), 'a-library'],
			[Iterable(['SL4B_Accessor']), 'sl4bdummy->SL4B_Accessor']
		]);
		const givenAST = getAST('add-require-for-global-identifier', 'given');
		addRequireForGlobalIdentifierVisitor.initialize(identifiersToRequire, givenAST.program.body);

		// When
		visit(givenAST, addRequireForGlobalIdentifierVisitor);

		// Then
		verifyASTIsAsExpected('add-require-for-global-identifier', 'expected', givenAST);
	});
export function SetTodos(todos) {
    //create a Immutable collection of Todo models.
    //We use Immutable.Iterable, and them convert to List at the end, to avoid the expense of
    //creating an extra intermediate list (the Iterable is just a wrapper around the array)
    const models = Immutable.Iterable(todos)
        .map(Todo)
        .toList();

    return model => noError(model.set('todos', models));
}
Esempio n. 5
0
IndexedCursorPrototype.getIn = function(key, notSetValue) {
  if (!Array.isArray(key)) {
    key = Immutable.Iterable(key).toArray();
  }
  if (key.length === 0) {
    return this;
  }
  var value = this._rootData.getIn(this._keyPath.concat(key), NOT_SET);
  return value === NOT_SET ? notSetValue : wrappedValue(this, key, value);
}
 TypedMap.prototype.__forceIterables = function(args) {
   // This forces all arguments into an iterable, which makes all the
   // merge functions avoid calling `fromJS` and converting them
   // deeply into immutable objects.
   const iters = [];
   for(var i=0; i<args.length; i++) {
     if(!Immutable.Iterable.isIterable(args[i])) {
       iters.push(Immutable.Iterable(args[i]));
     }
     else {
       iters.push(args[i]);
     }
   }
   return iters;
 };
Esempio n. 7
0
	return through2.obj(function(fileMetadata, encoding, callback) {
		// Verify that the streamlink variable is free to use in this module, if not generate a variation on it that is.
		verifyVarIsAvailableVisitor.initialize();
		visit(fileMetadata.ast, verifyVarIsAvailableVisitor);
		const freeSLJSVariation = verifyVarIsAvailableVisitor.getFreeVariation('sljs');

		// Replace all calls to a certain namespace with calls to the new SLJS identifier.
		flattenMemberExpression.initialize(['caplin', 'streamlink'], freeSLJSVariation);
		visit(fileMetadata.ast, flattenMemberExpression);

		// Add a require that requires SLJS into the module.
		const libraryIdentifiersToRequire = new Map([
			[Iterable([freeSLJSVariation]), 'sljs']
		]);

		addRequireForGlobalIdentifierVisitor.initialize(libraryIdentifiersToRequire, fileMetadata.ast.program.body);
		visit(fileMetadata.ast, addRequireForGlobalIdentifierVisitor);

		this.push(fileMetadata);
		callback();
	});
export default function stubImmutableIterable() {
  return Iterable([])
}
Esempio n. 9
0
		this._namespaceRoots = namespaceRoots.map(rootNamespace => Iterable([rootNamespace]));