當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。