diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..267d27e --- /dev/null +++ b/.eslintrc @@ -0,0 +1,20 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "array-bracket-newline": 0, + "array-bracket-spacing": 1, + "indent": [2, 4], + }, + + "overrides": [ + { + "files": "example/**", + "rules": { + "no-console": 0, + }, + }, + ], +} diff --git a/example/map.js b/example/map.js index 3365621..e4c538c 100644 --- a/example/map.js +++ b/example/map.js @@ -1,3 +1,5 @@ +'use strict'; + var concatMap = require('../'); var xs = [ 1, 2, 3, 4, 5, 6 ]; var ys = concatMap(xs, function (x) { diff --git a/index.js b/index.js index b29a781..3b0e9d3 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,18 @@ +'use strict'; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + module.exports = function (xs, fn) { var res = []; for (var i = 0; i < xs.length; i++) { var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); + if (isArray(x)) { + res.push.apply(res, x); + } else { + res.push(x); + } } return res; }; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; diff --git a/package.json b/package.json index ecc1879..befaab9 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,16 @@ "test": "test" }, "scripts": { + "lint": "eslint --ext=js,mjs .", + "pretest": "npm run lint", "tests-only": "tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "aud --production" }, "devDependencies": { + "@ljharb/eslint-config": "^21.0.0", "aud": "^2.0.1", + "eslint": "=8.8.0", "tape": "^5.6.1" }, "license": "MIT", diff --git a/test/map.js b/test/map.js index fdbd702..5c877ad 100644 --- a/test/map.js +++ b/test/map.js @@ -1,3 +1,5 @@ +'use strict'; + var concatMap = require('../'); var test = require('tape');