Skip to content

Commit cc9c430

Browse files
committed
refactor: move to es6, Maps and Sets
BREAKING CHANGE: moves to es6, works with node 4+
1 parent 9c7c542 commit cc9c430

File tree

12 files changed

+236
-294
lines changed

12 files changed

+236
-294
lines changed

.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": [
3+
"transform-es2015-spread",
4+
"transform-es2015-destructuring",
5+
"transform-strict-mode",
6+
"transform-es2015-parameters",
7+
"transform-es2015-shorthand-properties",
8+
"transform-object-rest-spread",
9+
"transform-class-properties"
10+
]
11+
}

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33

44
[*]
55
indent_style = space
6-
indent_size = 4
6+
indent_size = 2
77
end_of_line = lf
88
charset = utf-8
99
trim_trailing_whitespace = true

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "airbnb/base",
3+
"parser": "babel-eslint",
4+
"rules": {
5+
"no-param-reassign": [2,{"props": false}],
6+
"max-len": [2, 150],
7+
}
8+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ tags
3030
.cache
3131

3232
reports
33+
lib

.jshintrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist
2525
TAGS
2626
tags
2727
.tags
28+
src

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Vitaly Aminev
3+
Copyright (c) 2015-2016 Vitaly Aminev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,31 @@ One example would be conserving resources spent on outgoing http requests.
1515
2. `callbackQueue.remove(String, Error)`: calls queued callbacks with Error argument
1616

1717
```js
18-
var callbackQueue = require('callback-queue');
19-
var request = require('request');
18+
const callbackQueue = require('callback-queue');
19+
const request = require('request');
2020

2121
function performOutgoingRequest(url, next) {
22-
var callback = callbackQueue.add(url, next);
23-
if (!callback) {
24-
return;
25-
}
22+
const callback = callbackQueue.add(url, next);
23+
if (!callback) {
24+
return;
25+
}
2626

27-
request(url, callback);
27+
request(url, callback);
2828
}
2929

30-
for (var i = 0; i < 100; i++) {
31-
32-
// request itself will be performed just once
33-
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
34-
// will be called 100 times
35-
});
36-
30+
for (let i = 0; i < 100; i++) {
31+
// request itself will be performed just once
32+
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
33+
// will be called 100 times
34+
});
3735
}
3836

39-
for (var x = 0; x < 100; x++) {
40-
41-
// request itself will be performed just once
42-
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
43-
// will be called 100 times with Error object
44-
});
45-
37+
for (let x = 0; x < 100; x++) {
38+
// request itself will be performed just once
39+
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
40+
// will be called 100 times with Error object
41+
});
4642
}
4743

4844
callbackQueue.remove('https://google.com', new Error('cancel it!'));
49-
5045
```

index.js

Lines changed: 0 additions & 134 deletions
This file was deleted.

package.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"name": "callback-queue",
3-
"version": "1.1.1",
3+
"version": "2.0.0",
44
"description": "Put your callbacks into queue to make sure that concurrent requests that you might want to perform will only be executed once",
5-
"main": "index.js",
5+
"main": "./lib/callback-queue.js",
66
"scripts": {
7-
"test": "multi='spec=- xunit=test-report.xml' ./node_modules/.bin/mocha -R mocha-multi ./test/index.js"
7+
"test": "./node_modules/.bin/mocha -r babel-register -R spec test",
8+
"prepublish": "npm run compile",
9+
"pretest": "npm run compile",
10+
"compile": "./node_modules/.bin/babel -d ./lib src"
811
},
912
"repository": {
1013
"type": "git",
@@ -22,12 +25,17 @@
2225
"author": "Vitaly Aminev <[email protected]>",
2326
"license": "MIT",
2427
"dependencies": {
25-
"debug": "^2.1.3",
26-
"lodash.omit": "^3.1.0"
28+
"debug": "^2.2.0"
2729
},
2830
"devDependencies": {
29-
"chai": "^2.2.0",
30-
"mocha": "^2.2.1",
31-
"mocha-multi": "^0.6.0"
31+
"babel-cli": "^6.4.5",
32+
"babel-eslint": "^5.0.0",
33+
"babel-preset-es2015": "^6.3.13",
34+
"babel-preset-stage-0": "^6.3.13",
35+
"babel-register": "^6.5.2",
36+
"chai": "^3.5.0",
37+
"eslint": "^1.10.3",
38+
"eslint-config-airbnb": "^5.0.1",
39+
"mocha": "^2.4.5"
3240
}
3341
}

0 commit comments

Comments
 (0)