Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/function each in separate file #335

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,134 changes: 1,426 additions & 708 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions caniuse-db-category-js/array-find-index.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/array-find.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/array-flat.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/array-includes.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/arrow-functions.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/asmjs.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/async-clipboard.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/async-functions.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/bigint.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/const.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/constraint-validation.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/date-tolocaledatestring.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/decorators.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es5.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-class.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-generators.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-module-dynamic-import.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-module.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-number.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6-string-includes.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/es6.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/import-maps.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/internationalization.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/intl-pluralrules.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/js-regexp-lookbehind.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/json.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/let.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/localecompare.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/object-entries.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/object-fit.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/object-observe.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/object-values.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/objectrtc.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/pad-start-end.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/private-class-fields.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/private-methods-and-accessors.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/promise-finally.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/promises.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/proxy.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/rest-parameters.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/sharedarraybuffer.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/template-literals.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/temporal.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/typedarrays.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/unhandledrejection.json
1 change: 1 addition & 0 deletions caniuse-db-category-js/use-strict.json
Binary file added docs/pic/android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/ie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/ios_saf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/opera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/safari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pic/samsung.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
"scripts": {
"coveralls": "cat ./coverage/lcov.info | coveralls",
"test": "istanbul cover tests",
"test:unit": "mocha tests/unit"
"test:unit": "mocha tests/unit",
"build-readme": "node ./scripts/build-readme.js"
},
"dependencies": {
"kebab-case": "^1.0.0"
},
"devDependencies": {
"caniuse-api": "^3.0.0",
"caniuse-db": "^1.0.30001307",
"coveralls": "^2.11.9",
"eslint": "^4.18.2",
"istanbul": "^0.4.4",
Expand Down
83 changes: 83 additions & 0 deletions readme_src/000-head.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# [You don't (may not) need Lodash/Underscore](https://you-dont-need.github.io/You-Dont-Need-Lodash-Underscore/#/)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/you-dont-need/lodash-underscore)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cht8687/You-Dont-Need-Lodash-Underscore)

Lodash and Underscore are great modern JavaScript utility libraries, and they are widely used by Front-end developers. However, when you are targeting modern browsers, you may find out that there are many methods which are already supported natively thanks to ECMAScript5 [ES5] and ECMAScript2015 [ES6]. If you want your project to require fewer dependencies, and you know your target browser clearly, then you may not need Lodash/Underscore.

You are welcome to contribute with more items provided below.

* If you are targeting legacy JavaScript engine with those ES5 methods, you can use [es5-shim](https://github.com/es-shims/es5-shim)

* Please note that, the examples used below are just showing you the native alternative of performing certain tasks. For some functions, Lodash provides you more options than native built-ins. This list is not a 1:1 comparison.

* Please send a PR if you want to add or modify the code. No need to open an issue unless it's something big and you want to discuss.


## Voice of Developers

> [Make use of native JavaScript object and array utilities before going big.](https://twitter.com/codylindley/status/692356631007342593)

> &mdash;<cite>Cody Lindley, Author of [jQuery Cookbook](http://shop.oreilly.com/product/9780596159788.do) and [JavaScript Enlightenment](http://shop.oreilly.com/product/0636920027713.do)</cite>

<!-- -->
> [You probably don't need Lodash. Nice List of JavaScript methods which you can use natively.](https://twitter.com/daniellmb/status/692200768556916740)

> &mdash;<cite>Daniel Lamb, Computer Scientist, Technical Reviewer of [Secrets of the JavaScript Ninja](https://www.manning.com/books/secrets-of-the-javascript-ninja-second-edition) and [Functional Programming in JavaScript](https://www.manning.com/books/functional-programming-in-javascript)</cite>

<!-- -->
> [I guess not, but I want it.](https://twitter.com/teropa/status/692280179666898944)

> &mdash;<cite>Tero Parviainen, Author of [build-your-own-angular](http://teropa.info/build-your-own-angular)</cite>

<!-- -->
> [I'll admit, I've been guilty of overusing #lodash. Excellent resource.](https://twitter.com/therebelrobot/status/692907269512642561)

> &mdash;<cite>@therebelrobot, Maker of web things, Facilitator for Node.js/io.js</cite>


## ESLint Plugin

<p align="center">
<a href="https://www.npmjs.com/package/eslint-plugin-you-dont-need-lodash-underscore">
<img src="https://img.shields.io/npm/v/eslint-plugin-you-dont-need-lodash-underscore.svg?style=flat-square"
alt="NPM Version">
</a>
<a href="https://www.npmjs.org/package/eslint-plugin-you-dont-need-lodash-underscore">
<img src="http://img.shields.io/npm/dm/eslint-plugin-you-dont-need-lodash-underscore.svg?style=flat-square"
alt="Downloads">
</a>
<a href="https://travis-ci.org/you-dont-need/You-Dont-Need-Lodash-Underscore">
<img src="https://img.shields.io/travis/you-dont-need/You-Dont-Need-Lodash-Underscore/master.svg?style=flat-square"
alt="Build Status">
</a>
<a href="https://coveralls.io/github/you-dont-need/You-Dont-Need-Lodash-Underscore?branch=master">
<img src="https://img.shields.io/coveralls/you-dont-need/You-Dont-Need-Lodash-Underscore/master.svg?style=flat-square"
alt="Coverage Status" />
</a>
<a href="https://david-dm.org/you-dont-need/You-Dont-Need-Lodash-Underscore">
<img src="https://img.shields.io/david/you-dont-need/You-Dont-Need-Lodash-Underscore.svg?style=flat-square"
alt="Dependency Status">
</a>
</p>

If you're using [ESLint](http://eslint.org/), you can install a
[plugin](http://eslint.org/docs/user-guide/configuring#using-the-configuration-from-a-plugin) that
will help you identify places in your codebase where you don't (may not) need Lodash/Underscore.

Install the plugin...

```sh
npm install --save-dev eslint-plugin-you-dont-need-lodash-underscore
```

...then update your config

```js
"extends" : ["plugin:you-dont-need-lodash-underscore/compatible"],
```

For more information, see [Configuring the ESLint Plugin](configuring.md)

*:heavy_exclamation_mark:<b>Important:</b> Note that, while many Lodash methods are null safe (e.g. _.keys, _.entries),
this is not necessarily the case for their Native equivalent. If null safety is critical for your application, we
suggest that you take extra precautions [e.g. consider using the native Object.keys as Object.keys(value || {})].*
Empty file added readme_src/000-head/.keep
Empty file.
1 change: 1 addition & 0 deletions readme_src/010-Array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Array
Empty file added readme_src/010-Array/.keep
Empty file.
31 changes: 31 additions & 0 deletions readme_src/010-Array/chunk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### _.chunk

Creates an array of elements split into groups the length of size.
```js
// Underscore/Lodash
_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]

_.chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]


// Native

const chunk = (input, size) => {
return input.reduce((arr, item, idx) => {
return idx % size === 0
? [...arr, [item]]
: [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
}, []);
};

chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]

chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]

```

<!-- caniuse: es6 -->
13 changes: 13 additions & 0 deletions readme_src/010-Array/compact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### _.compact

Creates an array with all falsy values removed.

```js
// Underscore/Lodash
_.compact([0, 1, false, 2, '', 3]);

// Native
[0, 1, false, 2, '', 3].filter(Boolean)
```

<!-- caniuse: es6 -->
21 changes: 21 additions & 0 deletions readme_src/010-Array/concat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### _.concat

Creates a new array concatenating array with any additional arrays and/or values.

```js
// Underscore/Lodash
var array = [1]
var other = _.concat(array, 2, [3], [[4]])

console.log(other)
// output: [1, 2, 3, [4]]

// Native
var array = [1]
var other = array.concat(2, [3], [[4]])

console.log(other)
// output: [1, 2, 3, [4]]
```

<!-- caniuse: es5 -->
25 changes: 25 additions & 0 deletions readme_src/010-Array/difference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### _.difference
Similar to [without](#_without), but returns the values from array that are not present in the other arrays.

```js
// Underscore/Lodash
console.log(_.difference([1, 2, 3, 4, 5], [5, 2, 10]))
// output: [1, 3, 4]

// Native
var arrays = [[1, 2, 3, 4, 5], [5, 2, 10]];
console.log(arrays.reduce(function(a, b) {
return a.filter(function(value) {
return !b.includes(value);
});
}));
// output: [1, 3, 4]

// ES6
let arrays = [[1, 2, 3, 4, 5], [5, 2, 10]];
console.log(arrays.reduce((a, b) => a.filter(c => !b.includes(c))));
// output: [1, 3, 4]
```

<!-- caniuse: array-includes -->
<!-- caniuse: es5 -->
21 changes: 21 additions & 0 deletions readme_src/010-Array/drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### _.drop

Creates a slice of array with n elements dropped from the beginning.

```js
// Underscore/Lodash
_.drop([1, 2, 3]);
// => [2, 3]

_.drop([1, 2, 3], 2);
// => [3]

// Native
[1, 2, 3].slice(1);
// => [2, 3]

[1, 2, 3].slice(2);
// => [3]
```

<!-- caniuse: es5 -->
21 changes: 21 additions & 0 deletions readme_src/010-Array/dropRight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### _.dropRight

Creates a slice of array with n elements dropped at the end.

```js
// Underscore/Lodash
_.dropRight([1, 2, 3]);
// => [1, 2]

_.dropRight([1, 2, 3], 2);
// => [1]

// Native
[1, 2, 3].slice(0, -1);
// => [1, 2]

[1, 2, 3].slice(0, -2);
// => [1]
```

<!-- caniuse: es5 -->
Loading