Skip to content

Commit f7d0042

Browse files
authored
Various improvements for the docs and stuff (#7)
* Simplifing documentation a bit - make it less formal * Run tests in newer versions of node as well * Add coveralls integration
1 parent eee8801 commit f7d0042

File tree

5 files changed

+65
-61
lines changed

5 files changed

+65
-61
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
language: node_js
22
node_js:
33
- "6"
4+
- "8"
5+
- "10"
6+
script:
7+
- npm run test:ci
8+

COMPARE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Comparison with other libraries
22

33
## [Ramda](http://ramdajs.com/)
4-
Ramda was a massive influence on Tinkoff Utils It borrowed the same functional programming approach, naming, and many other things. However, Tinkoff Utils doesn't provide placeholders, lenses and some other less popular stuff.
4+
Ramda was a huge inspiration for Tinkoff Utils! it has a lot of similarities with naming style, uses same functional programming approach and many other things, with lack of some less popular design ideas like `__` prefixes, lenses and etc
55

66
| Ramda | Utils |
77
| --- | ------ |
@@ -114,8 +114,8 @@ Ramda was a massive influence on Tinkoff Utils It borrowed the same functional p
114114

115115

116116
## [Lodash](https://lodash.com/)
117-
Be careful when migrating from lodash to Utils:
118-
1. Check function signature, since Utils uses data as the last argument in contrast with lodash
117+
When migrating from lodash to Utils, keep in mind that –
118+
1. Lodash has different function signatures, since Utils uses data as the last argument in contrast with lodash
119119
1. Singular lodash methods can accept various argument types when Utils functions are focused and cohesive
120120
1. Some Lodash functions mutate passed arguments
121121

CONTRIBUTING.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
# Contributing
2-
1. Fork this repository.
3-
1. Install dependencies with `npm install`.
4-
1. Make sure tests are passing running `npm run test`.
5-
1. Make your changes. Make sure the commands `npm run build` and `npm run test` are not failing.
6-
1. Finally send a GitHub Pull Request with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).
2+
1. Fork this repository
3+
1. Create a future branch (don't make changes in master branch)
4+
1. Install dependencies with `npm install`
5+
1. Make sure tests are passing by running `npm test`
6+
1. Make your changes. Make sure `npm run build` and `npm test` will not fail
7+
1. Send us pull request with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit) and have tests
78

89
## How to add new utility
9-
1. Decide where to place new utility according to the structure of the library.
10-
1. Pick the name of the new utility (corresponding to the functionality or well-known name if there is analog in other libraries (ramda, lodash))
11-
1. Create a new file with picked named in the corresponding directory, and add a file with the same name to the '_\_tests__' directory.
12-
1. Implement new functionality. For autocurrying wrap utility to `/function/curry` or `/function/curryN` (`curry` doesn't support default and rest arguments, so prefer `curryN`).
13-
1. Add tests (don't forget edge cases and exceptions).
14-
1. Add JSDoc with the description of functionality, arguments types and a little example.
10+
1. Pick the descriptive name for the new utility
11+
1. Decide where to place it
12+
1. Create a new file with the same name at the proper path, and add a file with the same name to the `__tests__` directory
13+
1. Implement new functionality
14+
1. Add tests (don't forget edge cases and exceptions)
15+
1. Add JSDoc with the description of functionality, arguments types and a small example
1516

16-
## How to write JSDoc right
17-
List of supported tags is [here](https://esdoc.org/manual/tags.html).
17+
**Protip**: For autocurrying wrap utility to `/function/curry` or `/function/curryN` (`curry` doesn't support default and rest arguments, so for the most cases use `curryN`)
18+
19+
## How to write JSDoc
20+
First, check out [documentation](https://esdoc.org/manual/tags.html) for all supported tags.
1821

1922
JSDoc should contain the following:
20-
1. The description of a utility.
21-
1. Add arguments types and description for them (see @param).
22-
1. Add the type and the description of the return value (see @return).
23-
1. Add an example to demonstrate the usage of a utility (see @example).
23+
1. Description of a utility
24+
1. Arguments types and description for them (see [`@param`](http://usejsdoc.org/tags-param.html))
25+
1. Add type and description for the return value (see [`@return`](http://usejsdoc.org/tags-returns.html))
26+
1. Add an example to demonstrate the usage of a utility (see [`@example`](http://usejsdoc.org/tags-example.html))
2427

25-
If there is some additional information you want to add, prepend it with `**Note:**`.
28+
If there is some additional information you want to add, prepend it with `**Note:**`
2629

2730
### Example
28-
```javascript
31+
```js
2932
import curryN from '../function/curryN';
3033

3134
/**
@@ -37,7 +40,6 @@ import curryN from '../function/curryN';
3740
* @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
3841
* otherwise.
3942
* @example
40-
*
4143
* var lessThan0 = x => x < 0;
4244
* var lessThan2 = x => x < 2;
4345
* any(lessThan0)([1, 2]); //=> false

README.md

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
1-
# Tinkoff Utils
2-
[![Build Status](https://travis-ci.org/TinkoffCreditSystems/utils.js.svg?branch=master)](https://travis-ci.org/TinkoffCreditSystems/utils.js)
1+
# Tinkoff Utils [![Build](https://travis-ci.org/TinkoffCreditSystems/utils.js.svg?branch=master)](https://travis-ci.org/TinkoffCreditSystems/utils.js) [![Coverage Status](https://coveralls.io/repos/github/TinkoffCreditSystems/utils.js/badge.svg?branch=master&t=CdowK8)](https://coveralls.io/github/TinkoffCreditSystems/utils.js?branch=master)
32

4-
JavaScript utility library with the primary task to simplify work with data, functions, promises, and more.
5-
The main goals of the library are modularity, functional style, performance, and simplicity.
3+
> Fast, small and purely functional utility library
64
7-
## Example
8-
Installation
9-
```bash
10-
$ npm i --save @tinkoff/utils
5+
## Install
6+
```
7+
$ npm install @tinkoff/utils
118
```
129

13-
Usage
14-
```javascript
10+
## Features
11+
- [Fast](#benchmarks)
12+
- [Small](#bundle-size)
13+
- [Fully tested](https://coveralls.io/github/TinkoffCreditSystems/utils.js)
14+
- [Documented](https://tinkoffcreditsystems.github.io/utils.js)
15+
- Purely functional
16+
- Modern codebase
17+
18+
## Structure of the library
19+
* [`/object`](./src/object) – for objects
20+
* [`/string`](./src/string) – for strings
21+
* [`/promise`](./src/promise) – for promises
22+
* [`/array`](./src/array) – for arrays or array-like objects
23+
* [`/function`](./src/function) – for functions – composition, currying and so on, also a set of simple functions (noop, T, F)
24+
* [`/is`](./src/is) – set of type checking methods
25+
* [`/`](./src) – root contains utilities which don't satisfy any of the above categories or are universal
26+
27+
## Usage
28+
```js
1529
import pathOr from '@tinkoff/utils/object/pathOr';
1630
import compose from '@tinkoff/utils/function/compose';
1731
import toLower from '@tinkoff/utils/string/toLower';
@@ -24,29 +38,10 @@ const toLowerName = compose(
2438
const result = map(toLowerName)([{name: 'testA'}, {name: 'testb'}])
2539
```
2640

27-
## Features
28-
- Modular structure: utilities are located each in its file, structured by type.
29-
- Written with performance in mind.
30-
- Suitable for functional programming: every utility is a pure function with the order of arguments, convenient for currying.
31-
- Modern codebase: project is written in ES2015+.
32-
- Safe and secure to use: every utility is documented and covered with tests.
33-
34-
## The structure of the library
35-
* `/array`: a set of utilities to operate on arrays or array-like objects;
36-
* `/function`: a set of utilities to operate on functions (composition, currying and so on), also a set of simple functions (noop, T, F);
37-
* `/is`: a set of type-checking utilities;
38-
* `/object`: a set of utilities to operate on objects;
39-
* `/promise`: a set of promise utilities;
40-
* `/string`: a set of utilities to work with strings;
41-
* `/`: the root contains utilities that don't satisfy any of the above categories or are universal.
42-
43-
## Comparison with other libraries
44-
The comparison is between Tinkoff Utils and the following libraries:
45-
* lodash 4.7.14
46-
* ramda 0.22.1
47-
48-
### Benchmarks
49-
You can find benchmarks in the `__benchmarks__` directory.
41+
## Benchmarks
42+
```bash
43+
$ npm run benchmark
44+
```
5045

5146
| Utility | Lodash | Ramda | Utils |
5247
| --- | --- | --- | --- |
@@ -57,8 +52,7 @@ You can find benchmarks in the `__benchmarks__` directory.
5752
| object/path | 12,023,128 ops/sec | 8,894,639 ops/sec | 7,587,076 ops/sec |
5853
| string/trim | 4,215,928 ops/sec | 1,034,655 ops/sec | 6,029,794 ops/sec |
5954

60-
### Bundle size
61-
Bubdle size is compared to each other with the assumption that we need only a small subset of library methods (see details [here](./bundleSize)):
55+
## Bundle size
6256
| Library | Bundle size |
6357
| --- | --- |
6458
| import _ from 'lodash' | 70.1 kb |
@@ -67,4 +61,4 @@ Bubdle size is compared to each other with the assumption that we need only a sm
6761
| import ... from 'ramda/src/...' | 10 kb |
6862
| import ... from '@tinkoff/utils/...' | 2.32 kb |
6963

70-
The detailed comparison with specific library see [COMPARE.md](./COMPARE.md)
64+
For detailed comparison with specific libraries see [COMPARE.md](./COMPARE.md)

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"prebenchmark": "npm install --no-save lodash ramda lazy.js underscore",
99
"docs": "esdoc",
1010
"test": "jest --coverage",
11-
"pretest": "npm install --no-save react"
11+
"test:ci": "npm run test && cat ./coverage/lcov.info | coveralls"
1212
},
13-
"description": "JavaScript utility library for simplifying the work with data, functions, promises, etc.",
13+
"description": "Fast, small and purely functional utility library",
1414
"repository": "https://github.com/TinkoffCreditSystems/utils.js",
15+
"bugs": "https://github.com/TinkoffCreditSystems/utils.js/issues",
1516
"keywords": [
1617
"tinkoff",
1718
"utils",
@@ -28,6 +29,7 @@
2829
"babel-preset-react": "^6.24.1",
2930
"benchmark": "^2.1.4",
3031
"chalk": "^2.4.1",
32+
"coveralls": "^3.0.1",
3133
"esdoc": "^1.1.0",
3234
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
3335
"esdoc-importpath-plugin": "^1.0.2",
@@ -37,6 +39,7 @@
3739
"inquirer": "^5.2.0",
3840
"jest": "^23.0.0",
3941
"ora": "^2.1.0",
42+
"react": "^16.4.1",
4043
"walker": "^1.0.7"
4144
}
4245
}

0 commit comments

Comments
 (0)