From 9f5bef732b44e47a0b2b4e042500c4c98cabbd74 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 8 Apr 2019 11:01:16 +0000 Subject: [PATCH 1/3] Improve TypeScript definition, refactor definition to CommonJS compatible export (#8) --- index.d.ts | 34 ++++++++++++++++++++-------------- index.js | 1 - index.test-d.ts | 4 ++-- package.json | 6 +++--- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/index.d.ts b/index.d.ts index 12a94e1..3a038ea 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,15 +1,21 @@ /** - * Create an array with values that are present in the first array but not additional ones. - * - * @param array - The array to compare against. - * @param values - The arrays with values to be excluded. - * @returns A new array of filtered values. - * - * @example - * - * import arrayDiffer from 'array-differ'; - * - * arrayDiffer([2, 3, 4], [3, 50]); - * //=> [2, 4] - */ -export default function arrayDiffer(array: ArrayLike, ...values: ArrayLike[]): T[]; +Create an array with values that are present in the first array but not additional ones. + +@param array - The array to compare against. +@param values - The arrays with values to be excluded. +@returns A new array of filtered values. + +@example +``` +import arrayDiffer = require('array-differ'); + +arrayDiffer([2, 3, 4], [3, 50]); +//=> [2, 4] +``` +*/ +declare function arrayDiffer( + array: readonly ValueType[], + ...values: (readonly ValueType[])[] +): ValueType[]; + +export = arrayDiffer; diff --git a/index.js b/index.js index 1ef9418..6656fbe 100644 --- a/index.js +++ b/index.js @@ -6,4 +6,3 @@ const arrayDiffer = (array, ...values) => { }; module.exports = arrayDiffer; -module.exports.default = arrayDiffer; diff --git a/index.test-d.ts b/index.test-d.ts index 6ad424e..dadcbbc 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ -import {expectType} from 'tsd-check'; -import arrayDiffer from '.'; +import {expectType} from 'tsd'; +import arrayDiffer = require('.'); expectType(arrayDiffer(['a', 'b', 'c'], ['b'], ['c'])); expectType(arrayDiffer([1, 2, 3], [2], [3])); diff --git a/package.json b/package.json index 371229e..157d2ff 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo && ava && tsd-check" + "test": "xo && ava && tsd" }, "files": [ "index.js", @@ -28,8 +28,8 @@ "exclude" ], "devDependencies": { - "ava": "^1.2.1", - "tsd-check": "^0.3.0", + "ava": "^1.4.1", + "tsd": "^0.7.2", "xo": "^0.24.0" } } From 3bedc960bd862946bc445a4f19bd5820e9dcbdee Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 8 Apr 2019 18:03:19 +0700 Subject: [PATCH 2/3] Require Node.js 8 --- .editorconfig | 2 +- .gitattributes | 2 +- .gitignore | 1 + .travis.yml | 4 ++-- index.js | 2 +- license | 20 ++++---------------- package.json | 2 +- 7 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.editorconfig b/.editorconfig index 98a761d..1c6314a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,6 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[{package.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 176a458..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 3c3629e..239ecff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +yarn.lock diff --git a/.travis.yml b/.travis.yml index c9c9848..f3fa8cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false language: node_js node_js: - - '6' + - '10' + - '8' diff --git a/index.js b/index.js index 6656fbe..0dab1b8 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const arrayDiffer = (array, ...values) => { const rest = new Set([].concat(...values)); - return array.filter(x => !rest.has(x)); + return array.filter(element => !rest.has(element)); }; module.exports = arrayDiffer; diff --git a/license b/license index 654d0bf..e7af2f7 100644 --- a/license +++ b/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json index 157d2ff..004234f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" From 547a0fb7fe391f94f9993e9b1cbd62e9f6f1056d Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 8 Apr 2019 18:04:15 +0700 Subject: [PATCH 3/3] 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 004234f..e4ade95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "array-differ", - "version": "2.1.0", + "version": "3.0.0", "description": "Create an array with values that are present in the first input array but not additional ones", "license": "MIT", "repository": "sindresorhus/array-differ",