- Fork this repository
- Create a future branch (don't make changes in master branch)
- Install dependencies with
npm install
- Make sure tests are passing by running
npm test
- Make your changes. Make sure
npm run build
andnpm test
will not fail - Send us pull request with a clear list of what you've done (read more about pull requests). Make sure all of your commits are atomic (one feature per commit) and have tests
- Pick the descriptive name for the new utility
- Decide where to place it
- Create a new file with the same name at the proper path, and add a file with the same name to the
__tests__
directory - Implement new functionality
- Add tests (don't forget edge cases and exceptions)
- Add JSDoc with the description of functionality, arguments types and a small example
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
)
First, check out documentation for all supported tags.
JSDoc should contain the following:
- Description of a utility
- Arguments types and description for them (see
@param
) - Add type and description for the return value (see
@return
) - Add an example to demonstrate the usage of a utility (see
@example
)
If there is some additional information you want to add, prepend it with **Note:**
import curryN from '../function/curryN';
/**
* Returns `true` if at least one of elements of the list match the predicate,
* `false` otherwise.
*
* @param {Function} fn The predicate function.
* @param {Array} arr The array to consider.
* @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
* otherwise.
* @example
* var lessThan0 = x => x < 0;
* var lessThan2 = x => x < 2;
* any(lessThan0)([1, 2]); //=> false
* any(lessThan2)([1, 2]); //=> true
*/
export default curryN(2, (fn, arr = []) => {
for (let i = 0; i < arr.length; i++) {
if (fn(arr[i], i, arr)) {
return true;
}
}
return false;
});