Skip to content

Commit 0236b77

Browse files
committed
Upgraded Webpack to 1.14.0
1 parent 24daf54 commit 0236b77

File tree

14 files changed

+957
-733
lines changed

14 files changed

+957
-733
lines changed

.eslintrc.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"extends": [
3-
"eslint:recommended",
4-
"google"
3+
"airbnb-base",
4+
"plugin:import/warnings",
5+
"plugin:import/errors"
6+
],
7+
"plugins": [
8+
"import"
59
],
610
"root": true,
711
"env": {
@@ -20,13 +24,18 @@
2024
}
2125
},
2226
"rules": {
27+
"import/no-extraneous-dependencies": [
28+
"error", { "devDependencies": true }
29+
],
2330
"valid-jsdoc": [1, {
2431
"requireReturnDescription": false
2532
}],
2633
"one-var": [2, {
2734
"uninitialized": "always"
2835
}],
2936
"max-len": 0,
30-
"object-curly-spacing": [2, "never"]
37+
"object-curly-spacing": [2, "never"],
38+
"no-underscore-dangle": 0,
39+
"no-param-reassign": 0
3140
}
3241
}

README.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Array sort-by
1+
# Array sortBy
22

33
<!-- markdownlint-disable MD033 MD034 MD014 -->
44

5-
The motivation to create this function was to provide a mechanism that allow sort lists of elements,
6-
with the possibility to specify multiple sort criteria.
5+
The motivation for creating this utility was to provide a mechanism to organize elements,
6+
with the ability to specify multiple ordering criteria.
77

88
## Getting started
99

@@ -45,10 +45,12 @@ function parser(item, index);
4545
`array-sort-by` can be included directly from a CDN in your page:
4646

4747
```html
48-
<!-- last version: 1.0.1 -->
49-
<script src="https://cdn.rawgit.com/jherax/array-sort-by/1.0.1/dist/sort-by.min.js"></script>
48+
<!-- last version: 1.0.2 -->
49+
<script src="https://cdn.rawgit.com/jherax/array-sort-by/1.0.2/dist/sort-by.min.js"></script>
5050
```
5151

52+
In the above case, the function [`sortBy`](#examples) is included as a global object in the browser.
53+
5254
As this library is built as an [UMD](http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/)
5355
(Universal Module Definition), it can be included from a module loader as AMD, CommonJS, or ES2015 Export.
5456

@@ -67,16 +69,20 @@ import sortBy from 'array-sort-by';
6769
### AMD
6870

6971
```javascript
72+
// using RequireJS
7073
requirejs.config({
7174
paths: {
75+
// remove the extension .js
7276
'array-sort-by': '<PATH>/sort-by.min'
7377
}
7478
});
75-
define(['array-sort-by'], function(sortBy) {
79+
require(['array-sort-by'], function(sortBy) {
7680
sortBy(someArray);
7781
});
7882
```
7983

84+
See an example with RequireJS here: http://jsfiddle.net/FdKTn/66/
85+
8086
## Examples
8187

8288
### Default sorting (ASC)
@@ -103,7 +109,7 @@ sortBy(arr, n => -n);
103109
*/
104110
```
105111

106-
### Sorting DESC date-strings in format `'yyyy/MM/dd'` as `Date`
112+
### Sorting DESC date-strings as `Date`
107113

108114
```javascript
109115
let arr = ["1983/03/06", "1980/12/24", "1985/08/31", "1983/03/05"];
@@ -133,21 +139,21 @@ sortBy(arr, (s) => "desc:" + s);
133139

134140
```javascript
135141
let arr = [
136-
{ n: 8, d: "1985/08/31" },
137-
{ n: 2, d: "1980/12/24" },
138-
{ n: 5, d: "1983/03/06" },
139-
{ n: 8, d: "1983/03/06" }
142+
{ a: 8, d: "1985/08/31" },
143+
{ a: 2, d: "1980/12/24" },
144+
{ a: 5, d: "1983/03/06" },
145+
{ a: 8, d: "1983/03/06" }
140146
];
141147

142-
sortBy(arr, (o) => [-o.n, new Date(o.d)]);
148+
sortBy(arr, (o) => [-o.a, new Date(o.d)]);
143149

144150
/*
145151
* expected:
146152
* [
147-
* { n: 8, d: "1983/03/06" },
148-
* { n: 8, d: "1985/08/31" },
149-
* { n: 5, d: "1983/03/06" },
150-
* { n: 2, d: "1980/12/24" }
153+
* { a: 8, d: "1983/03/06" },
154+
* { a: 8, d: "1985/08/31" },
155+
* { a: 5, d: "1983/03/06" },
156+
* { a: 2, d: "1980/12/24" }
151157
* ]
152158
*/
153159
```
@@ -179,21 +185,21 @@ sortBy(arr, (o) => "DESC:" + o.name.toUpperCase());
179185

180186
```javascript
181187
let arr = [
182-
{ id: 4, name: "pedro", age: 26 },
183-
{ id: 6, name: "Pedro", age: 32 },
184-
{ id: 7, name: "Luis", age: 26 },
185-
{ id: 2, name: "luis", age: 26 }
188+
{ a: 4, age: 26, name: "pedro" },
189+
{ a: 6, age: 32, name: "Pedro" },
190+
{ a: 7, age: 26, name: "Luis" },
191+
{ a: 2, age: 26, name: "luis" }
186192
];
187193

188-
sortBy(arr, (o) => [o.name.toUpperCase(), -o.age, o.id]);
194+
sortBy(arr, (o) => [o.name.toUpperCase(), -o.age, o.a]);
189195

190196
/*
191197
* expected:
192198
* [
193-
* { id: 2, name: "luis", age: 26 },
194-
* { id: 7, name: "Luis", age: 26 },
195-
* { id: 6, name: "Pedro", age: 32 },
196-
* { id: 4, name: "pedro", age: 26 }
199+
* { a: 2, age: 26, name: "luis" },
200+
* { a: 7, age: 26, name: "Luis" },
201+
* { a: 6, age: 32, name: "Pedro" },
202+
* { a: 4, age: 26, name: "pedro" }
197203
* ]
198204
*/
199205
```
@@ -204,15 +210,22 @@ If you want to fork or build your own, you must run this project.
204210

205211
### Requirements
206212

207-
1. Git ([git-linux](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) or [git-windows](https://git-for-windows.github.io/)).
208-
1. [Node.js](https://nodejs.org/en/) (latest stable version v6+).
209-
1. Node Package Manager ([npm](https://docs.npmjs.com/) v3+), the one that comes with your **node.js** version.<br>
210-
It is preferable to install Node Version Manager - **[nvm](https://github.com/creationix/nvm)**, it contains both
211-
**node.js** and **npm**.
213+
1. Git ([git-linux](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
214+
or [git-windows](https://git-for-windows.github.io/)).
215+
1. [Node.js](https://nodejs.org/en/) (latest stable version v6+).<br>
216+
It is preferable install **[nvm](https://github.com/creationix/nvm)**
217+
(Node Version Manager).
212218
1. [Yarn](https://yarnpkg.com/en/docs/cli/) installed as a global package.
213219

214-
**NOTE**: Consider to install Node Version Manager (**NVM**) to upgrade easily the Node.js version.<br>
215-
Go to https://github.com/creationix/nvm and check the installation process for your OS.
220+
**NOTE**: Consider install Node Version Manager (**nvm**) to upgrade easily the NodeJS version.
221+
<br>Go to https://github.com/creationix/nvm and check the installation process for your OS.
222+
223+
If you are running Windows, you can install
224+
[nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows).
225+
Follow every step mentioned
226+
[here](https://github.com/coreybutler/nvm-windows#installation--upgrades)
227+
so that nvm will be correctly installed to manage multiple installations
228+
of **node.js** (with **npm**) on a Windows computer.
216229

217230
### Building the project
218231

@@ -240,9 +253,7 @@ And finally execute the webpack task:
240253
$ yarn run build
241254
```
242255

243-
This command will lint the code with [ESLint](http://eslint.org/docs/user-guide/getting-started) and after that
244-
it will transpile with [Babel](https://babeljs.io/) the ES2015 Module in `src/` folder to an UMD ES5 Module in `dist/`
245-
and finally it will generate the minified and source map files.
256+
This command will lint the code with [ESLint](http://eslint.org/docs/user-guide/getting-started) and transpile the source files from `src/` to `dist/` as an [UMD](http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) with [Babel](https://babeljs.io/). It also generates the minified and source map files.
246257

247258
## Versioning
248259

dist/sort-by.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
/*! sortBy@v1.0.2. Jherax 2017. Visit https://github.com/jherax/array-sort-by */
12
(function webpackUniversalModuleDefinition(root, factory) {
23
if(typeof exports === 'object' && typeof module === 'object')
34
module.exports = factory();
45
else if(typeof define === 'function' && define.amd)
5-
define([], factory);
6+
define("sortBy", [], factory);
67
else if(typeof exports === 'object')
78
exports["sortBy"] = factory();
89
else
@@ -114,8 +115,8 @@ return /******/ (function(modules) { // webpackBootstrap
114115
* @return {Number}
115116
*/
116117
function sortItems(aprev, anext) {
117-
var sorted = void 0,
118-
i = void 0;
118+
var i = void 0,
119+
sorted = void 0;
119120
for (i in aprev) {
120121
// eslint-disable-line
121122
sorted = comparer(aprev[i], anext[i]);
@@ -133,9 +134,9 @@ return /******/ (function(modules) { // webpackBootstrap
133134
* @param {Any} next: n+1 element to compare
134135
* @return {Number}
135136
*/
136-
var defaultSort = function defaultSort(prev, next) {
137+
function defaultSort(prev, next) {
137138
return prev < next ? -1 : +(prev > next);
138-
};
139+
}
139140

140141
/**
141142
* @public

dist/sort-by.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)