Skip to content

Commit 34cf46c

Browse files
authored
Merge pull request #6 from georapbox/ver2
Closes #3
2 parents 1218669 + 5256c73 commit 34cf46c

34 files changed

+5673
-6900
lines changed

.babelrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"presets": ["es2015"],
3-
"plugins": [
4-
"babel-plugin-add-module-exports"
5-
]
2+
"presets": ["@babel/env"]
63
}

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ratings:
1717
paths:
1818
- src/**
1919
exclude_paths:
20-
- lib/**/*
20+
- dist/**/*
2121
- test/**/*
2222
- coverage/**/*
2323
- .nyc_output/**/*

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist/**
2+
/lib/**

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
"no-whitespace-before-property": 1,
277277

278278
// enforce consistent spacing inside braces
279-
"object-curly-spacing": [1, "never"],
279+
"object-curly-spacing": 0,
280280

281281
// enforce the consistent use of either backticks, double, or single quotes
282282
"quotes": [1, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],

.gitignore

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,65 @@
1-
# dependencies
2-
/node_modules
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
319

4-
# testing
5-
/coverage
20+
# nyc test coverage
621
.nyc_output
722

23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# production
61+
dist
62+
lib
63+
864
# misc
965
.DS_Store
10-
.env
11-
npm-debug.log*
12-
yarn-debug.log*
13-
yarn-error.log*
14-
demo.js

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- 8.1.3
3+
- 8.11.1
44
branches:
55
only:
66
- master

CHAGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
# CHANGELOG
22

3+
## v2.0.0
4+
5+
### BREAKING CHANGES
6+
7+
> The library's API has not breaking changes. All breaking changes refer to how the final distributed files are bundled and their locations in the project.
8+
9+
- All distributed files are located under the `dist/` directory instead of `lib/` which was in v1.x.x. The UMD format is located under `dist/umd/` directory and the CommonJS under the `dist/commonjs/` directory.
10+
- The directory containing the distributed files is no longer included in GIT.
11+
12+
### OTHER CHANGES
13+
14+
- All `devDependencies` are updated to latest versions. Updated Webpack to v4.x.x and Babel to v7.x.x.
15+
- The library is now exported in both UMD (as was in version 1.x.x) and CommonJS. For CommonJS, the libdary's methods are also exported as standalone functions in order to import only the ones you want for your project. Check the [Usage](https://github.com/georapbox/immutable-arrays/blob/master/README.md#usage) section in README for more details.
16+
17+
318
## v1.0.3
419

520
- Fixes issue #4. Do not copy array unnecessarily in `del` method if index is a negative number.
621

22+
723
## v1.0.2
824

925
- Use the array spread operator in delete method.
1026
- Keep devDependencies up to date.
1127

28+
1229
## v1.0.1
1330

1431
- Keep devDependencies up to date.
@@ -32,14 +49,17 @@ Below is a list with the renamed methods:
3249
- `immutableSort` renamed to `sort`;
3350
- `immutableDelete` renamed to `del`;
3451

52+
3553
## v0.4.3
3654
- Include test coverage in build process
3755
- Add test to cover scenario with all optional arguments being undefined for immutableSplice method
3856

57+
3958
## v0.4.2
4059
- Keep devDependencies up to date
4160
- Add code climate integration
4261
- Add test coverage report
4362

63+
4464
## v0.4.1
4565
- Fix bug while deleting an element at 0 index [(#1)](https://github.com/georapbox/immutable-arrays/pull/1)

README.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,29 @@ $ npm install --save immutable-arrays
2121

2222
## Usage
2323

24+
The library is exported in `UMD` and `CommonJS` formats under `dist/umd` and `dist/commonjs` directories respectively.
25+
It can be used both in Browser and Node environments.
26+
In Node environment or if you use a bundler (eg Webpack), the library also exports all of its methods as CommonJS standalone functions under the `dist/commonjs` directory.
27+
2428
### Old school browser global
2529
```html
26-
<script src="immutable-arrays/lib/immutableArrays.min.js"></script>
30+
<script src="immutable-arrays/dist/umd/immutable-arrays.min.js"></script>
2731
```
2832

2933
### Node.js
34+
35+
#### Import the whole library
36+
3037
```js
3138
const immutableArrays = require('immutable-arrays');
3239
```
3340

41+
#### Import only the module you need <sup>New in version 2.x.x</sup>
42+
43+
```js
44+
const push = require('immutable-arrays/dist/commonjs/push').default;
45+
```
46+
3447
### ES2015 imports
3548

3649
#### Import default export
@@ -39,22 +52,22 @@ const immutableArrays = require('immutable-arrays');
3952
import immutableArrays from 'immutable-arrays';
4053
```
4154

42-
#### Import a single export
55+
#### Import a named export (bundlers like Webpack will still include the whole library)
4356

4457
```js
45-
import {push} from 'immutable-arrays';
58+
import { push } from 'immutable-arrays';
4659
```
4760

48-
#### Import multiple exports
61+
#### Import only the module you need <sup>New in version 2.x.x</sup>
4962

5063
```js
51-
import {push, pop, shift} from 'immutable-arrays';
64+
import push from 'immutable-arrays/dist/commonjs/push';
5265
```
5366

54-
#### Import ES2015 (uncompiled) method from source
67+
#### Import ES2015 (uncompiled) function from source
5568

5669
```js
57-
import push from 'immutable-arrays/src/immutable-push';
70+
import push from 'immutable-arrays/src/push';
5871
```
5972

6073
## API
@@ -258,18 +271,32 @@ const resultArray = immutableArrays.del(originalArray, 2);
258271
// -> originalArray ['a', 'b', 'c', 'd', 'e']
259272
// -> resultArray ['a', 'b', 'd', 'e']
260273

261-
const resultArray2 = immutableDelete(originalArray, -1);
274+
const resultArray2 = immutableArrays.del(originalArray, -1);
262275
// -> originalArray ['a', 'b', 'c', 'd', 'e']
263276
// -> resultArray2 ['a', 'b', 'c', 'd', 'e']
264277
```
265278

266-
## Test
279+
## For developers
280+
281+
### Build the library
282+
283+
```sh
284+
$ npm run dev
285+
```
286+
Builds the library and watches for changes while developing. If you want to build only for a specific format, there are other npm scripts available; check in `package.json`.
287+
288+
```sh
289+
$ npm run build
290+
```
291+
Builds the library for production.
292+
293+
### Run the tests
267294

268295
```sh
269-
$ npm test
296+
$ npm run test
270297
```
271298

272-
## Test Coverage
299+
### Tests coverage
273300

274301
```sh
275302
$ npm run coverage

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./src').default;

0 commit comments

Comments
 (0)