Require Node.js 8
This commit is contained in:
parent
ea4204f0b4
commit
120f74ab63
5 changed files with 34 additions and 43 deletions
|
|
@ -2,4 +2,3 @@ language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '10'
|
- '10'
|
||||||
- '8'
|
- '8'
|
||||||
- '6'
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
},
|
},
|
||||||
"main": "dist",
|
"main": "dist",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=8"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "del dist && tsc",
|
"build": "del dist && tsc",
|
||||||
|
|
@ -54,11 +54,13 @@
|
||||||
"@typescript-eslint/eslint-plugin": "^1.5.0",
|
"@typescript-eslint/eslint-plugin": "^1.5.0",
|
||||||
"ava": "^1.4.1",
|
"ava": "^1.4.1",
|
||||||
"del-cli": "^1.1.0",
|
"del-cli": "^1.1.0",
|
||||||
|
"eslint-config-xo-typescript": "^0.9.0",
|
||||||
"jsdom": "^11.6.2",
|
"jsdom": "^11.6.2",
|
||||||
"rxjs": "^6.4.0",
|
"rxjs": "^6.4.0",
|
||||||
"tempy": "^0.2.1",
|
"tempy": "^0.2.1",
|
||||||
"ts-node": "^8.0.3",
|
"ts-node": "^8.0.3",
|
||||||
"typescript": "^3.4.1",
|
"typescript": "^3.4.1",
|
||||||
|
"xo": "^0.24.0",
|
||||||
"zen-observable": "^0.8.8"
|
"zen-observable": "^0.8.8"
|
||||||
},
|
},
|
||||||
"types": "dist",
|
"types": "dist",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
/// <reference lib="es2016"/>
|
/// <reference lib="es2017"/>
|
||||||
/// <reference lib="es2017.sharedmemory"/>
|
|
||||||
/// <reference lib="esnext.asynciterable"/>
|
/// <reference lib="esnext.asynciterable"/>
|
||||||
/// <reference lib="dom"/>
|
/// <reference lib="dom"/>
|
||||||
|
|
||||||
|
|
@ -145,7 +144,7 @@ is.nativePromise = (value: unknown): value is Promise<unknown> =>
|
||||||
const hasPromiseAPI = (value: unknown): value is Promise<unknown> =>
|
const hasPromiseAPI = (value: unknown): value is Promise<unknown> =>
|
||||||
!is.null_(value) &&
|
!is.null_(value) &&
|
||||||
isObject(value) as unknown &&
|
isObject(value) as unknown &&
|
||||||
is.function_((value as Promise<unknown>).then) &&
|
is.function_((value as Promise<unknown>).then) && // eslint-disable-line promise/prefer-await-to-then
|
||||||
is.function_((value as Promise<unknown>).catch);
|
is.function_((value as Promise<unknown>).catch);
|
||||||
|
|
||||||
is.promise = (value: unknown): value is Promise<unknown> => is.nativePromise(value) || hasPromiseAPI(value);
|
is.promise = (value: unknown): value is Promise<unknown> => is.nativePromise(value) || hasPromiseAPI(value);
|
||||||
|
|
@ -180,7 +179,7 @@ is.arrayBuffer = isObjectOfType<ArrayBuffer>(TypeName.ArrayBuffer);
|
||||||
is.sharedArrayBuffer = isObjectOfType<SharedArrayBuffer>(TypeName.SharedArrayBuffer);
|
is.sharedArrayBuffer = isObjectOfType<SharedArrayBuffer>(TypeName.SharedArrayBuffer);
|
||||||
is.dataView = isObjectOfType<DataView>(TypeName.DataView);
|
is.dataView = isObjectOfType<DataView>(TypeName.DataView);
|
||||||
|
|
||||||
is.directInstanceOf = <T>(instance: unknown, klass: Class<T>): instance is T => Object.getPrototypeOf(instance) === klass.prototype;
|
is.directInstanceOf = <T>(instance: unknown, class_: Class<T>): instance is T => Object.getPrototypeOf(instance) === class_.prototype;
|
||||||
is.urlInstance = (value: unknown): value is URL => isObjectOfType<URL>(TypeName.URL)(value);
|
is.urlInstance = (value: unknown): value is URL => isObjectOfType<URL>(TypeName.URL)(value);
|
||||||
|
|
||||||
is.urlString = (value: unknown): value is string => {
|
is.urlString = (value: unknown): value is string => {
|
||||||
|
|
|
||||||
60
test/test.ts
60
test/test.ts
|
|
@ -10,7 +10,6 @@ import {Subject, Observable} from 'rxjs';
|
||||||
import ZenObservable from 'zen-observable';
|
import ZenObservable from 'zen-observable';
|
||||||
import is from '../source';
|
import is from '../source';
|
||||||
|
|
||||||
const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8;
|
|
||||||
const isNode10orHigher = Number(process.versions.node.split('.')[0]) >= 10;
|
const isNode10orHigher = Number(process.versions.node.split('.')[0]) >= 10;
|
||||||
|
|
||||||
class PromiseSubclassFixture<T> extends Promise<T> {}
|
class PromiseSubclassFixture<T> extends Promise<T> {}
|
||||||
|
|
@ -223,55 +222,55 @@ const types = new Map<string, Test>([
|
||||||
['int8Array', {
|
['int8Array', {
|
||||||
is: is.int8Array,
|
is: is.int8Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Int8Array(0)
|
new Int8Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['uint8Array', {
|
['uint8Array', {
|
||||||
is: is.uint8Array,
|
is: is.uint8Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Uint8Array(0)
|
new Uint8Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['uint8ClampedArray', {
|
['uint8ClampedArray', {
|
||||||
is: is.uint8ClampedArray,
|
is: is.uint8ClampedArray,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Uint8ClampedArray(0)
|
new Uint8ClampedArray()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['int16Array', {
|
['int16Array', {
|
||||||
is: is.int16Array,
|
is: is.int16Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Int16Array(0)
|
new Int16Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['uint16Array', {
|
['uint16Array', {
|
||||||
is: is.uint16Array,
|
is: is.uint16Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Uint16Array(0)
|
new Uint16Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['int32Array', {
|
['int32Array', {
|
||||||
is: is.int32Array,
|
is: is.int32Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Int32Array(0)
|
new Int32Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['uint32Array', {
|
['uint32Array', {
|
||||||
is: is.uint32Array,
|
is: is.uint32Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Uint32Array(0)
|
new Uint32Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['float32Array', {
|
['float32Array', {
|
||||||
is: is.float32Array,
|
is: is.float32Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Float32Array(0)
|
new Float32Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['float64Array', {
|
['float64Array', {
|
||||||
is: is.float64Array,
|
is: is.float64Array,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
new Float64Array(0)
|
new Float64Array()
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
['arrayBuffer', {
|
['arrayBuffer', {
|
||||||
|
|
@ -480,21 +479,17 @@ test('is.error', t => {
|
||||||
testType(t, 'error');
|
testType(t, 'error');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isNode8orHigher) {
|
test('is.nativePromise', t => {
|
||||||
test('is.nativePromise', t => {
|
testType(t, 'nativePromise');
|
||||||
testType(t, 'nativePromise');
|
});
|
||||||
});
|
|
||||||
|
|
||||||
test('is.promise', t => {
|
test('is.promise', t => {
|
||||||
testType(t, 'promise', ['nativePromise']);
|
testType(t, 'promise', ['nativePromise']);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*-
|
test('is.asyncFunction', t => {
|
||||||
test('is.asyncFunction', t => {
|
testType(t, 'asyncFunction', ['function']);
|
||||||
testType(t, 'asyncFunction', ['function']);
|
});
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
test('is.generator', t => {
|
test('is.generator', t => {
|
||||||
testType(t, 'generator');
|
testType(t, 'generator');
|
||||||
|
|
@ -691,18 +686,15 @@ test('is.class', t => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('is.typedArray', t => {
|
test('is.typedArray', t => {
|
||||||
// TypeScript currently does not support empty constructors for these
|
|
||||||
// See https://github.com/Microsoft/TypeScript/issues/19680
|
|
||||||
// TODO: Remove the `0` when targeting `es2017` (Node.js 8), in other places of this file too.
|
|
||||||
const typedArrays = [
|
const typedArrays = [
|
||||||
new Int8Array(0),
|
new Int8Array(),
|
||||||
new Uint8Array(0),
|
new Uint8Array(),
|
||||||
new Uint8ClampedArray(0),
|
new Uint8ClampedArray(),
|
||||||
new Uint16Array(0),
|
new Uint16Array(),
|
||||||
new Int32Array(0),
|
new Int32Array(),
|
||||||
new Uint32Array(0),
|
new Uint32Array(),
|
||||||
new Float32Array(0),
|
new Float32Array(),
|
||||||
new Float64Array(0)
|
new Float64Array()
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const item of typedArrays) {
|
for (const item of typedArrays) {
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@
|
||||||
"extends": "@sindresorhus/tsconfig",
|
"extends": "@sindresorhus/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"target": "es2016",
|
"target": "es2017",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2016",
|
"es2017",
|
||||||
"es2017.sharedmemory",
|
|
||||||
"esnext.asynciterable",
|
"esnext.asynciterable",
|
||||||
"dom"
|
"dom"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue