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


TypeScript ramda.last函数代码示例

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


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

示例1: toPath

export const match = (modifier: string, props: MatchProps = {}) => {
  if (modifier === SELF_MODIFIER_NAME) {
    return true
  }

  const modifierPath = toPath(modifier)

  const linearMatch = target => {
    const value = path(modifierPath, target)

    if (is(Boolean, value)) {
      return value
    }

    if (isNil(value)) {
      return false
    }

    return !isEmpty(value)
  }

  const matcher =
    modifierPath.length > 1
      ? pathEq(init(modifierPath), last(modifierPath))
      : linearMatch

  return matcher(props)
}
开发者ID:monstrs,项目名称:elementum,代码行数:28,代码来源:match.ts

示例2: 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

示例3: if

  tokens.forEach((token) => {
    const { image } = token;

    if (bracketsCount === 0 && image !== '(' && image !== ')') {
      output.push(token);
      return;
    }

    temp.push(token);
    if (image === '(') {
      bracketsCount += 1;
    } else if (image === ')') {
      bracketsCount -= 1;

      if (bracketsCount === 0) {
        // recursive clean within parenthesis, unnests one layer
        const cleaned = cleanOperators(temp.slice(1, -1));
        if (cleaned.length) {
          // Length check means this is fine
          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
          output.push(R.head(temp)!, ...cleaned, R.last(temp)!);
        }
        temp = [];
      }
    }
  });
开发者ID:nusmodifications,项目名称:nusmods,代码行数:26,代码来源:parseString.ts

示例4: it

  it(`upToWithProcessEngine '${n}' iterations`, async() => {
    const fizzbuzzUpTo = processEngine.execute('fizzy-upTo');

    const actual = await fizzbuzzUpTo({upTo: n + 1, i: 1});

    expect(actual.length).toEqual(n);
    expect(R.last(actual)).toEqual('buzz');
  });
开发者ID:sprengerjo,项目名称:katas_js,代码行数:8,代码来源:test_fizzbuzz.spec.ts

示例5: wrap

    wrap(text: string, columns: number): string {
        const wrap = s => this.wrap(s, columns);
        const splitAtColumns = R.splitAt(columns);

        if (R.length(text) <= columns) {
            return text;
        }

        if (R.not(containsSpaces(text))) {
            return R.head(splitAtColumns(text)) + NEW_LINE + wrap(R.last(splitAtColumns(text)));
        }

        if (SPACE === text[columns]) {
            return R.head(splitAtColumns(text)) + NEW_LINE + wrap(R.trim(splitAtColumns(text)[1]));
        }

        return replaceLastSpace(R.head(splitAtColumns(text))) + wrap(R.last(splitAtColumns(text)));
    }
开发者ID:paucls,项目名称:katas,代码行数:18,代码来源:wrapper.ts

示例6: setKey

function setKey(to: any, keyPath: string[], type: string, from: any): void {
  let key = R.last(keyPath);
  if (!from.hasOwnProperty(key)) return;

  let value = from[key];
  ConfigTypeError.assert(keyPath.join('.'), type, value);

  to[key] = value;
}
开发者ID:programble,项目名称:careen,代码行数:9,代码来源:load.ts

示例7: getNextNumber

  /**
   * Return the next running number in an array of records
   * @param {string} prop The property name
   * @param data The array of records containing the property
   */
  static getNextNumber(prop: string, data: Array<any>) {
    if (R.isEmpty(data)) { return 1 }
    const getNextNumber = R.pipe(
      R.sortBy(R.prop(prop)),
      R.pluck(prop),
      R.last()
    );

    return parseInt(getNextNumber(data)) + 1;
  }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:15,代码来源:array-helper.ts

示例8: it

    it('submitting a correct solution after submitting a wrong solution enqueus the exercise again', () => {
      group.submit(false);
      group.submit(true);

      const exercises = group.getRemainingExercises();
      expect(exercises.length).toEqual(10);

      const lastExercise = R.last(exercises);
      expect(lastExercise && lastExercise.props.index).toEqual(0);
    });
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:10,代码来源:exercise-groups.ts

示例9:

    (acc: Array<BookmarkTree>, bookmarkTree) => {
      if (!acc.length) return [bookmarkTree]

      const prevBookmarkTree = R.last(acc)
      if (!prevBookmarkTree) throw new Error('prevBookmarkTree must exist')
      const updatedBookmarkTree = R.set(
        R.lensPath(['parent', 'parentId']),
        prevBookmarkTree.parent.id,
        bookmarkTree
      )
      return [...acc, updatedBookmarkTree]
    },
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:12,代码来源:getters.test.ts


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