Skip to content

Commit 83937bf

Browse files
committed
Some tweaks to the TS make file
1 parent 82acc59 commit 83937bf

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"git-branch": "^0.3.0",
171171
"has-ansi": "^2.0.0",
172172
"inquirer": "^2.0.0",
173+
"is-array-sorted": "^1.0.0",
173174
"lolex": "^1.4.0",
174175
"mkdirp": "^0.5.1",
175176
"nyc": "^10.0.0",

types/make.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
const path = require('path');
1616
const fs = require('fs');
17+
const isArraySorted = require('is-array-sorted');
1718
const runner = require('../lib/runner');
1819

19-
const arrayHas = parts => part => parts.indexOf(part) > -1;
20+
const arrayHas = parts => part => parts.indexOf(part) !== -1;
2021

2122
const base = fs.readFileSync(path.join(__dirname, 'base.d.ts'), 'utf8');
2223

@@ -35,13 +36,13 @@ function generatePrefixed(prefix) {
3536
for (const part of allParts) {
3637
const parts = prefix.concat([part]);
3738

38-
if (prefix.indexOf(part) > -1 || !verify(parts, true)) {
39+
if (prefix.indexOf(part) !== -1 || !verify(parts, true)) {
3940
// Function already in prefix or not allowed here
4041
continue;
4142
}
4243

4344
// If `parts` is not sorted, we alias it to the sorted chain
44-
if (!isSorted(parts)) {
45+
if (!isArraySorted(parts)) {
4546
const chain = parts.sort().join('.');
4647

4748
if (exists(parts)) {
@@ -55,7 +56,7 @@ function generatePrefixed(prefix) {
5556
// `always` is a valid prefix, for instance of `always.after`,
5657
// but not a valid function name.
5758
if (verify(parts, false)) {
58-
if (parts.indexOf('todo') > -1) {
59+
if (parts.indexOf('todo') !== -1) { // eslint-disable-line no-negated-condition
5960
output += '\t' + writeFunction(part, 'name: string', 'void');
6061
} else {
6162
const type = testType(parts);
@@ -147,17 +148,6 @@ function exists(parts) {
147148
return false;
148149
}
149150

150-
// Checks that an array is sorted
151-
function isSorted(a) {
152-
for (let i = 1; i < a.length; i++) {
153-
if (a[i - 1] >= a[i]) {
154-
return false;
155-
}
156-
}
157-
158-
return true;
159-
}
160-
161151
// Returns the type name of for the test implementation
162152
function testType(parts) {
163153
const has = arrayHas(parts);

0 commit comments

Comments
 (0)