Example #1
0
 it('always returns the same type', () => {
   var a = Set.of(1,2,3);
   var b = List();
   expect(b.concat(a)).not.toBe(a);
   expect(List.isList(b.concat(a))).toBe(true);
   expect(b.concat(a)).is(List.of(1,2,3));
 })
Example #2
0
export function makeFilesArg(value) {
    let globs = [];
    let objs = [];

    if (_.isString(value)) {
        globs = globs.concat(explodeFilesArg(value));
    }

    if (List.isList(value) && value.size) {
        value.forEach(function(value) {
            if (_.isString(value)) {
                globs.push(value);
            } else {
                if (Map.isMap(value)) {
                    objs.push(value);
                }
            }
        });
    }

    return {
        globs: globs,
        objs: objs
    };
}
Example #3
0
    flatMap(({ repoId, page }) => {
      if (List.isList(repoId)) {
        return fetchMapIssues(repoId as List<string>, store.value, page);
      }

      return fetchMapIssue(repoId as string, store.value, page);
    }),
Example #4
0
 .update('plugins', (x) => {
     // Ensure next transformation is always dealing with a List
     if (!Imm.List.isList(x)) {
         return Imm.List([x]);
     }
     return x;
 })
  it('can compose Immutable::List initial states', () => {
    const state = compose(List.of('a', 'b'), List.of('c', 'd'), List.of());
    expect(List.isList(state)).to.be.true;

    const plain = state.toJS();
    expect(plain).not.to.be.null;
    expect(plain).to.deep.equal(['a', 'b', 'c', 'd']);
  });
Example #6
0
export const append = <A>($1: Stream<A>, $2: Stream<A>): Stream<A> => {
    if (isLazy($1)) return () => append($2, $1());
    if (List.isList($1) && $1.isEmpty()) return $2;

    const newList = append($1.shift(), $2);
    return (isLazy(newList))
        ? () => append(List([$1.get(0)]), newList)
        : newList.unshift($1.get(0));
};
 transform(todos, args) {
   if (isBlank(args) || args.length === 0) {
     throw new BaseException('VisibleTodos pipe requires one argument');
   }
   if (isPresent(todos) && !List.isList(todos)) {
     return todos;
   }
   return this.getVisibleTodos(todos, args[0]);
 }
export function handleExtensionsOption(incoming: BsTempOptions): TransformResult {
    const value = incoming.get('extensions');
    if (_.isString(value)) {
        const split = explodeFilesArg(value);
        if (split.length) {
            return [incoming.set('extensions', List(split)), []];
        }
    }
    if (List.isList(value)) {
        return [incoming.set('extensions', value), []];
    }
    return [incoming, []];
}
export function addToFilesOption(incoming: BsTempOptions): TransformResult {
    if (!incoming.get("watch")) {
        return [incoming, []];
    }

    let serverPaths = [];

    const fromServeStatic = incoming
        .get("serveStatic", List([]))
        .toArray();
    const ssPaths = fromServeStatic
        .reduce((acc, ss) => {
            if (typeof ss === "string") {
                return acc.concat(ss);
            }
            if (ss.dir && typeof ss.dir === "string") {
                return acc.concat(ss);
            }
            return acc;
        }, []);

    ssPaths.forEach(p => serverPaths.push(p));

    const server = incoming.get("server");
    if (server) {
        if (server === true) {
            serverPaths.push(".");
        }
        if (typeof server === "string") {
            serverPaths.push(server);
        }
        if (
            List.isList(server) &&
            server.every(x => typeof x === "string")
        ) {
            server.forEach(s => serverPaths.push(s));
        }
        if (Map.isMap(server)) {
            const baseDirProp = server.get("baseDir");
            const baseDirs = List([]).concat(baseDirProp).filter(Boolean);
            baseDirs.forEach(s => serverPaths.push(s));
        }
    }

    const output = incoming.update("files", files => {
        return List([])
            .concat(files, serverPaths)
            .filter(Boolean);
    });
    return [output, []];
}
Example #10
0
export default (state = initialState, action: LabelAction) => {
  const { type, payload } = action;

  switch (type) {
    case ADD_LABEL:
      if (List.isList(payload)) {
        const payloadBis = payload.reduce((acc, next) => {
          return acc.set(next.get('id'), next);
        }, OrderedMap<any, any>());

        return state.merge(payloadBis);
      }
    default:
      return state;
  }
};