Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tinkoff/utils

Tinkoff2.7kApache-2.02.6.2TypeScript support: included

Fast, small and purely functional utility library

tinkoff, utils, ramda, lodash, curry, performance

readme

Tinkoff Utils Build status Coverage Status

Fast, small and purely functional utility library

Install

$ npm install @tinkoff/utils

Features

Structure of the library

  • /object – for objects
  • /string – for strings
  • /promise – for promises
  • /array – for arrays or array-like objects
  • /function – for functions – composition, currying and so on, also a set of simple functions (noop, T, F)
  • /is – set of type checking methods
  • / – root contains utilities which don't satisfy any of the above categories or are universal

Usage

import pathOr from '@tinkoff/utils/object/pathOr';
import compose from '@tinkoff/utils/function/compose';
import toLower from '@tinkoff/utils/string/toLower';
import map from '@tinkoff/utils/array/map'

const toLowerName = compose(
    toLower,
    pathOr(['name'], '')
);
const result = map(toLowerName)([{name: 'testA'}, {name: 'testb'}])

Benchmarks

$ npm run benchmark
Utility Lodash Ramda Utils
clone 120,807 ops/sec 112,053 ops/sec 293,572 ops/sec
array/filter 2,080,728 ops/sec 1,849,633 ops/sec 2,046,113 ops/sec
is/empty 1,506,963 ops/sec 474,177 ops/sec 3,731,564 ops/sec
function/flip 7,528,745 ops/sec 3,735,143 ops/sec 3,490,207 ops/sec
object/path 12,023,128 ops/sec 8,894,639 ops/sec 7,587,076 ops/sec
string/trim 4,215,928 ops/sec 1,034,655 ops/sec 6,029,794 ops/sec

Browser support

  • Chrome >= 40
  • Firefox >= 52
  • Edge >= 14
  • IE >= 11
  • Safari >= 10
  • iOS >= 10
  • Android >= 4.4

Node support

  • 6.4.0 and higher

Bundle size

Library Bundle size
import _ from 'lodash' 70.1 kb
import ... from 'lodash/...' 21.8 kb
import R from 'ramda' 41.3 kb
import ... from 'ramda/src/...' 10 kb
import ... from '@tinkoff/utils/...' 2.32 kb

For detailed comparison with specific libraries see COMPARE.md

changelog

2.6.2 (2023-08-01)

2.6.1 (2023-08-01)

Features

  • ci: add release workflow with release-it (777b741)

Bug Fixes

  • add files to publishing (49c0b80)
  • change token settings for release workflow (1a83c59)
  • fix publishing files (3c24d4b)
  • remove files property from package.json (541ee12)

2.2.1

  • add check into the utility isEqual for comparision of functions by reference (#63)

2.1.3

  • fix typings for object/groupBy

2.1.1

  • add is/reactComponent
  • is/reactElement now using react-is package if available
  • is/plainObject returns false for react components
  • clone will only copy the plain objects instead of copying any object with prototype or react components

2.1.0

  • add array/groupBy to group values in array by the list of predicates
  • add object/propSetBy and object/pathSetBy functions to allow setting values based on the result of function call
  • add utils/assign to create a shallow copy based on type
  • object/propSet, object/pathSet won't generate new reference when the object itself doesn't change
  • extend types for object/propApply, object/pathApply functions

2.0.0

  • add typings
  • move docs to branch gh-pages
  • add memoize functions
  • add is/shallowEqual
  • upgrade to babel@7
  • fix bug with omit string conversion
  • remove is/not
  • remove is/contains
  • remove sanitize
  • fix function/throttleEnd
  • fix array/shuffle random generator

1.0.2

  • Update docs and license

0.6.2

  • Add changelog
  • Convert utils build with babel