当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.flatten函数代码示例

本文整理汇总了TypeScript中ramda.flatten函数的典型用法代码示例。如果您正苦于以下问题:TypeScript flatten函数的具体用法?TypeScript flatten怎么用?TypeScript flatten使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了flatten函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: deps

 function deps(scss: string, exists: string[]): string[] {
     let excludes = new Set(exists);
     let lines = fs.readFileSync(scss, "utf-8").split("\n");
     let imports = Optional.cat(lines.map(l => depFromLine(l).map(p => path.resolve(path.dirname(scss), `${p}.scss`))));
     let targets = imports.filter(i => ! excludes.has(i));
     return targets.concat(_.flatten(targets.map(t => deps(t, exists.concat(targets)))));
 }
开发者ID:leon740727,项目名称:wcp,代码行数:7,代码来源:type-scss.ts

示例2: deps

 function deps(file: string, exists: string[]): string[] {
     let _deps = requires(fs.readFileSync(file, "utf-8"))
                 .map(dep => path.resolve(path.dirname(file), `${dep}.js`))
                 .filter(fs.existsSync)
                 .filter(dep => exists.indexOf(dep) == -1);
     return _.uniq(_deps.concat(_.flatten(_deps.map(d => deps(d, exists.concat(_deps))))));
 }
开发者ID:leon740727,项目名称:wcp,代码行数:7,代码来源:type-js.ts

示例3: rowGenerator

export function rowGenerator(state: State, table: string, schema: RelationTree): Route[] {

  let history: History = R.clone(state.history || []);

  if (history.length >= state.options.relationLimit) {
    return [];
  }

  let last = R.last(history);

  let relation = schema[table].relations[last && last['table']];
  let identifier = `${schema[table].model}_id`;
  if (relation) {
    history.push({
      type: 'row',
      table: table,
      model: schema[table].model
    });
  }
  else {
    history[0] = {
      type: 'row',
      table: table,
      model: schema[table].model,
      identifier: identifier
    };
  }

  let identifierString = state.options.idFormat === 'colons' ?
    `:${identifier}` : `{${identifier}}`;

  let newPath = relation ?
    `${state.path}/${schema[table].model}` :  `${state.path}/${identifierString}`;

  let newState = {
    options: state.options,
    path: newPath,
    history: history
  };

  let tables = R.flatten(Object.keys(schema[table].relations).map((relation) => {
    if (schema[table].relations[relation] === 'one') {
      return rowGenerator(newState, relation, schema);
    }
    else {
      return tableGenerator(newState, relation, schema);
    }
  }));

  return R.concat(
    scopes.row.methods.map((method) => {
      return {
        path: newPath,
        method: method,
        history: history
      };
    }),
    tables
  );
};
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:60,代码来源:pathGenerator.ts

示例4: subscribe

 /**
  * Subscribes to some paths in state. Allows the user to track a subset of
  * data within the state that will be sent to them every time it changes.
  *
  * @param command The command received from the reactotron app.
  */
 function subscribe(command: any) {
   const trackedNode = trackedNodes[command.mstNodeName || "default"]
   const paths: string[] = (command && command.payload && command.payload.paths) || []
   if (trackedNode && trackedNode.node && paths) {
     subscriptions = uniq(flatten(paths))
     const state = getSnapshot(trackedNode.node)
     sendSubscriptions(state)
   }
 }
开发者ID:nick121212,项目名称:reactotron,代码行数:15,代码来源:reactotron-mst.ts

示例5: getXAttrs

 .map(function getXAttrs(outlines:Array<OutlineFolderParent>):Array<OutlineFeed> {
     return flatten<any>( // fixme: use proper types!
         map(
             outline => isFeedItem(outline) ?
                 prop('$', outline) :
                 getXAttrs(getOutline(outline)),
             outlines
         )
     );
 })
开发者ID:r-k-b,项目名称:newsblur-feed-info,代码行数:10,代码来源:index.ts

示例6:

const getVocabularyRecursive = (node: AbstractNode): string[] => {
  if (node instanceof Leaf) {
    return node.getNewVocabulary();
  }
  const internalNode = node as InternalNode;

  return R.uniq([
    ...internalNode.getNewVocabulary(),
    ...R.flatten<string>(
      R.map(getVocabularyRecursive, internalNode.getChildren())
    )
  ]);
};
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:13,代码来源:check-assets.ts

示例7: getVocabulary

  public getVocabulary(id: string): string[] {
    if (this.getId() === id) {
      return this.getNewVocabulary();
    }

    const nodesUntilId = takeWhile(
      found => !found,
      map(child => child.findEntity(id), this.getChildren())
    );
    const previousChildren = take(nodesUntilId.length + 1, this.getChildren());

    return concat(
      flatten<string>(map(node => node.getVocabulary(id), previousChildren)),
      this.getNewVocabulary()
    );
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:16,代码来源:InternalNode.ts

示例8: getLetters

  public getLetters(id: string): string[] {
    const newLetterArr: string[] = this.getNewLetter()
      ? ([this.getNewLetter()] as string[])
      : [];
    if (this.getId() === id) {
      return newLetterArr;
    }

    const nodesUntilId = takeWhile(
      found => !found,
      map(child => child.findEntity(id), this.getChildren())
    );
    const previousChildren = take(nodesUntilId.length + 1, this.getChildren());

    return concat(
      flatten<string>(map(node => node.getLetters(id), previousChildren)),
      newLetterArr
    );
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:19,代码来源:InternalNode.ts

示例9: filter

  },
  // filter :: Filterable f => (a → Boolean) → f a → f a
  filter(fn, list) {
    return R.filter(fn, list)
  },
  // findIndex :: (a → Boolean) → [a] → Number
  findIndex(field, val, list) {
    return R.findIndex(R.propEq(field, val))(list)
  },
  // concat :: [a] → [a] → [a]
  concat(listA, listB) {
    return R.concat(listA, listB)
  },
  //flatten :: [a] → [b]
  flatten(list) {
    return R.flatten(list)
  },

  //// [{}] ////
  // getFullObjByField :: k -> [a] -> [a] -> {k:v}
  getFullObjByField(findField, partArr, fullArr) {
    return R.filter(R.where({ [findField]: R.contains(R.__, partArr) }))(fullArr)  // tslint:disable-line
  },
  // getAnotherField :: k -> [a] -> [a] -> {k:v} -> v
  getAnotherField(anotherField, findField, partArr, fullArr) {
    return this.pluck(anotherField, this.getFullObjByField(findField, partArr, fullArr))
  },
  // getArrObjByFieldValue :: (k->v->[{k:v}]) -> {k:v}
  getArrObjByFieldValue(field, filedValue, list) {
    return this.filter(R.propEq(field, filedValue), list)[0]
  },
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts

示例10: getPolygonFromPoints

      y
    })
  },
  getPolygonFromPoints (points: TwoDimensionalPoint[]): Line {
    const pointsSorted = R.sortWith([
      R.ascend(R.prop('x')),
      R.ascend(R.prop('y'))
    ])(points) as TwoDimensionalPoint[]

    const minPoint = pointsSorted[0]
    const maxPoint = R.last(pointsSorted)

    const pointsBellow = [minPoint].concat(pointsSorted.filter(point => {
      return isPointBellow(point, minPoint) && isPointBellow(point, maxPoint) && !R.equals(point, maxPoint)
    }))
    const pointsBellowPath = flatten ( zip( R.pluck('x', pointsBellow), R.pluck('y', pointsBellow) ) ) as number[]

    const pointsAbove = R.sortWith([
        R.descend(R.prop('x')),
        R.descend(R.prop('y'))
      ]
    )(R.difference(pointsSorted, pointsBellow))
    const pointsAbovePath = flatten ( zip( R.pluck('x', pointsAbove), R.pluck('y', pointsAbove) ) ) as number[]

    return new Line({
      points: pointsBellowPath.concat(pointsAbovePath),
      closed: true,
      stroke: '#fff',
      strokeWidth: 2,
      tension: 0.2
    })
开发者ID:neonerd,项目名称:weallmeetatthoseplaces,代码行数:31,代码来源:FaceGenerator.ts


注:本文中的ramda.flatten函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。