Skip to content
This repository was archived by the owner on Aug 8, 2020. It is now read-only.

Commit 79ffa90

Browse files
committed
ES2015ify and require Node.js 4
1 parent 94a20bc commit 79ffa90

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto
2+
*.js text eol=lf

.travis.yml

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
language: node_js
22
node_js:
33
- '6'
4-
- '5'
54
- '4'
6-
- '0.12'
7-
- '0.10'
8-
95
after_script:
106
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'

index.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
'use strict';
2-
var objectAssign = require('object-assign');
3-
4-
module.exports = function (options, fn, target) {
5-
var chainables = options.chainableMethods || {};
6-
var spread = options.spread;
7-
var defaults = objectAssign({}, options.defaults);
2+
module.exports = (options, fn, target) => {
3+
const chainables = options.chainableMethods || {};
4+
const spread = options.spread;
5+
const defaults = Object.assign({}, options.defaults);
86

97
function extend(target, getter, ctx) {
10-
Object.keys(chainables).forEach(function (key) {
8+
for (const key of Object.keys(chainables)) {
119
Object.defineProperty(target, key, {
1210
enumerable: true,
1311
configurable: true,
14-
get: function () {
12+
get() {
1513
return wrap(getter, chainables[key], ctx || this);
1614
}
1715
});
18-
});
16+
}
1917
}
2018

2119
function wrap(createOpts, extensionOpts, ctx) {
2220
function wrappedOpts() {
23-
return objectAssign(createOpts(), extensionOpts);
21+
return Object.assign(createOpts(), extensionOpts);
2422
}
2523

2624
function wrappedFn() {
27-
var args = new Array(arguments.length);
25+
let args = new Array(arguments.length);
2826

29-
for (var i = 0; i < args.length; i++) {
27+
for (let i = 0; i < args.length; i++) {
3028
args[i] = arguments[i];
3129
}
3230

@@ -45,7 +43,7 @@ module.exports = function (options, fn, target) {
4543
}
4644

4745
function copyDefaults() {
48-
return objectAssign({}, defaults);
46+
return Object.assign({}, defaults);
4947
}
5048

5149
if (target) {

package.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"url": "github.com/jamestalmage"
1111
},
1212
"engines": {
13-
"node": ">=0.10.0"
13+
"node": ">=4"
1414
},
1515
"scripts": {
16-
"test": "xo && nyc --cache --reporter=lcov --reporter=text ava"
16+
"test": "xo && nyc ava"
1717
},
1818
"files": [
1919
"index.js"
@@ -26,13 +26,16 @@
2626
"chainable",
2727
"fluent"
2828
],
29-
"dependencies": {
30-
"object-assign": "^4.0.1"
31-
},
3229
"devDependencies": {
33-
"ava": "^0.14.0",
30+
"ava": "^0.19.1",
3431
"coveralls": "^2.11.6",
35-
"nyc": "^6.4.4",
36-
"xo": "^0.15.1"
32+
"nyc": "^10.3.2",
33+
"xo": "^0.18.2"
34+
},
35+
"nyc": {
36+
"reporter": [
37+
"lcov",
38+
"text"
39+
]
3740
}
3841
}

test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import fn from './';
2+
import fn from '.';
33

44
test('defaults and args are passed', t => {
55
t.plan(2);
@@ -83,7 +83,7 @@ test('this is preserved', t => {
8383
notFoo: {foo: false},
8484
bar: {bar: true}
8585
}
86-
}, opts => {
86+
}, function (opts) {
8787
t.is(this, ctx);
8888
return opts;
8989
}, ctx);
@@ -102,7 +102,9 @@ test('this is preserved correctly using prototypes', t => {
102102
notFoo: {foo: false},
103103
bar: {bar: true}
104104
}
105-
}, opts => [this, opts], Constructor.prototype);
105+
}, function (opts) {
106+
return [this, opts];
107+
}, Constructor.prototype);
106108

107109
const c1 = new Constructor();
108110
const c2 = new Constructor();
@@ -119,7 +121,7 @@ test('spread option spreads arguments', t => {
119121
chainableMethods: {
120122
foo: {foo: true}
121123
}
122-
}, function returnArgs() {
124+
}, function () {
123125
return Array.prototype.slice.call(arguments);
124126
});
125127

0 commit comments

Comments
 (0)