Skip to content

Commit

Permalink
[eslint] fix indentation
Browse files Browse the repository at this point in the history
ljharb committed Oct 12, 2022

Verified

This commit was signed with the committer’s verified signature.
MindTooth Birger Johan Nordølum
1 parent e965df9 commit 7015b7b
Showing 5 changed files with 115 additions and 117 deletions.
28 changes: 13 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"root": true,
"root": true,

"extends": "@ljharb",
"extends": "@ljharb",

"rules": {
"array-bracket-newline": 0,
"array-bracket-spacing": 1,
"indent": [2, 4],
},
"rules": {
"array-bracket-newline": 0,
},

"overrides": [
{
"files": "example/**",
"rules": {
"no-console": 0,
},
},
],
"overrides": [
{
"files": "example/**",
"rules": {
"no-console": 0,
},
},
],
}
4 changes: 2 additions & 2 deletions example/map.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var concatMap = require('../');
var xs = [ 1, 2, 3, 4, 5, 6 ];
var xs = [1, 2, 3, 4, 5, 6];
var ys = concatMap(xs, function (x) {
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
return x % 2 ? [x - 0.1, x, x + 0.1] : [];
});
console.dir(ys);
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';

var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
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);
}
}
return res;
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);
}
}
return res;
};
128 changes: 64 additions & 64 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
{
"name": "concat-map",
"description": "concatenative mapdashery",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/substack/node-concat-map.git"
},
"main": "index.js",
"keywords": [
"concat",
"concatMap",
"map",
"functional",
"higher-order"
],
"directories": {
"example": "example",
"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",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"testling": {
"files": "test/*.js",
"browsers": {
"ie": [
6,
7,
8,
9
],
"ff": [
3.5,
10,
15
],
"chrome": [
10,
22
],
"safari": [
5.1
],
"opera": [
12
]
}
}
"name": "concat-map",
"description": "concatenative mapdashery",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/substack/node-concat-map.git"
},
"main": "index.js",
"keywords": [
"concat",
"concatMap",
"map",
"functional",
"higher-order"
],
"directories": {
"example": "example",
"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",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"testling": {
"files": "test/*.js",
"browsers": {
"ie": [
6,
7,
8,
9
],
"ff": [
3.5,
10,
15
],
"chrome": [
10,
22
],
"safari": [
5.1
],
"opera": [
12
]
}
}
}
50 changes: 25 additions & 25 deletions test/map.js
Original file line number Diff line number Diff line change
@@ -4,38 +4,38 @@ var concatMap = require('../');
var test = require('tape');

test('empty or not', function (t) {
var xs = [ 1, 2, 3, 4, 5, 6 ];
var ixes = [];
var ys = concatMap(xs, function (x, ix) {
ixes.push(ix);
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
});
t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]);
t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]);
t.end();
var xs = [1, 2, 3, 4, 5, 6];
var ixes = [];
var ys = concatMap(xs, function (x, ix) {
ixes.push(ix);
return x % 2 ? [x - 0.1, x, x + 0.1] : [];
});
t.same(ys, [0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1]);
t.same(ixes, [0, 1, 2, 3, 4, 5]);
t.end();
});

test('always something', function (t) {
var xs = [ 'a', 'b', 'c', 'd' ];
var ys = concatMap(xs, function (x) {
return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ];
});
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
t.end();
var xs = ['a', 'b', 'c', 'd'];
var ys = concatMap(xs, function (x) {
return x === 'b' ? ['B', 'B', 'B'] : [x];
});
t.same(ys, ['a', 'B', 'B', 'B', 'c', 'd']);
t.end();
});

test('scalars', function (t) {
var xs = [ 'a', 'b', 'c', 'd' ];
var ys = concatMap(xs, function (x) {
return x === 'b' ? [ 'B', 'B', 'B' ] : x;
});
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
t.end();
var xs = ['a', 'b', 'c', 'd'];
var ys = concatMap(xs, function (x) {
return x === 'b' ? ['B', 'B', 'B'] : x;
});
t.same(ys, ['a', 'B', 'B', 'B', 'c', 'd']);
t.end();
});

test('undefs', function (t) {
var xs = [ 'a', 'b', 'c', 'd' ];
var ys = concatMap(xs, function () {});
t.same(ys, [ undefined, undefined, undefined, undefined ]);
t.end();
var xs = ['a', 'b', 'c', 'd'];
var ys = concatMap(xs, function () {});
t.same(ys, [undefined, undefined, undefined, undefined]);
t.end();
});

0 comments on commit 7015b7b

Please sign in to comment.