forked from orbit-oss/is
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:
|
||||
- '10'
|
||||
- '8'
|
||||
- '6'
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
"main": "dist",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "del dist && tsc",
|
||||
|
|
@ -54,11 +54,13 @@
|
|||
"@typescript-eslint/eslint-plugin": "^1.5.0",
|
||||
"ava": "^1.4.1",
|
||||
"del-cli": "^1.1.0",
|
||||
"eslint-config-xo-typescript": "^0.9.0",
|
||||
"jsdom": "^11.6.2",
|
||||
"rxjs": "^6.4.0",
|
||||
"tempy": "^0.2.1",
|
||||
"ts-node": "^8.0.3",
|
||||
"typescript": "^3.4.1",
|
||||
"xo": "^0.24.0",
|
||||
"zen-observable": "^0.8.8"
|
||||
},
|
||||
"types": "dist",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference lib="es2016"/>
|
||||
/// <reference lib="es2017.sharedmemory"/>
|
||||
/// <reference lib="es2017"/>
|
||||
/// <reference lib="esnext.asynciterable"/>
|
||||
/// <reference lib="dom"/>
|
||||
|
||||
|
|
@ -145,7 +144,7 @@ is.nativePromise = (value: unknown): value is Promise<unknown> =>
|
|||
const hasPromiseAPI = (value: unknown): value is Promise<unknown> =>
|
||||
!is.null_(value) &&
|
||||
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.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.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.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 is from '../source';
|
||||
|
||||
const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8;
|
||||
const isNode10orHigher = Number(process.versions.node.split('.')[0]) >= 10;
|
||||
|
||||
class PromiseSubclassFixture<T> extends Promise<T> {}
|
||||
|
|
@ -223,55 +222,55 @@ const types = new Map<string, Test>([
|
|||
['int8Array', {
|
||||
is: is.int8Array,
|
||||
fixtures: [
|
||||
new Int8Array(0)
|
||||
new Int8Array()
|
||||
]
|
||||
}],
|
||||
['uint8Array', {
|
||||
is: is.uint8Array,
|
||||
fixtures: [
|
||||
new Uint8Array(0)
|
||||
new Uint8Array()
|
||||
]
|
||||
}],
|
||||
['uint8ClampedArray', {
|
||||
is: is.uint8ClampedArray,
|
||||
fixtures: [
|
||||
new Uint8ClampedArray(0)
|
||||
new Uint8ClampedArray()
|
||||
]
|
||||
}],
|
||||
['int16Array', {
|
||||
is: is.int16Array,
|
||||
fixtures: [
|
||||
new Int16Array(0)
|
||||
new Int16Array()
|
||||
]
|
||||
}],
|
||||
['uint16Array', {
|
||||
is: is.uint16Array,
|
||||
fixtures: [
|
||||
new Uint16Array(0)
|
||||
new Uint16Array()
|
||||
]
|
||||
}],
|
||||
['int32Array', {
|
||||
is: is.int32Array,
|
||||
fixtures: [
|
||||
new Int32Array(0)
|
||||
new Int32Array()
|
||||
]
|
||||
}],
|
||||
['uint32Array', {
|
||||
is: is.uint32Array,
|
||||
fixtures: [
|
||||
new Uint32Array(0)
|
||||
new Uint32Array()
|
||||
]
|
||||
}],
|
||||
['float32Array', {
|
||||
is: is.float32Array,
|
||||
fixtures: [
|
||||
new Float32Array(0)
|
||||
new Float32Array()
|
||||
]
|
||||
}],
|
||||
['float64Array', {
|
||||
is: is.float64Array,
|
||||
fixtures: [
|
||||
new Float64Array(0)
|
||||
new Float64Array()
|
||||
]
|
||||
}],
|
||||
['arrayBuffer', {
|
||||
|
|
@ -480,21 +479,17 @@ test('is.error', t => {
|
|||
testType(t, 'error');
|
||||
});
|
||||
|
||||
if (isNode8orHigher) {
|
||||
test('is.nativePromise', t => {
|
||||
testType(t, 'nativePromise');
|
||||
});
|
||||
test('is.nativePromise', t => {
|
||||
testType(t, 'nativePromise');
|
||||
});
|
||||
|
||||
test('is.promise', t => {
|
||||
testType(t, 'promise', ['nativePromise']);
|
||||
});
|
||||
test('is.promise', t => {
|
||||
testType(t, 'promise', ['nativePromise']);
|
||||
});
|
||||
|
||||
/*-
|
||||
test('is.asyncFunction', t => {
|
||||
testType(t, 'asyncFunction', ['function']);
|
||||
});
|
||||
*/
|
||||
}
|
||||
test('is.asyncFunction', t => {
|
||||
testType(t, 'asyncFunction', ['function']);
|
||||
});
|
||||
|
||||
test('is.generator', t => {
|
||||
testType(t, 'generator');
|
||||
|
|
@ -691,18 +686,15 @@ test('is.class', 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 = [
|
||||
new Int8Array(0),
|
||||
new Uint8Array(0),
|
||||
new Uint8ClampedArray(0),
|
||||
new Uint16Array(0),
|
||||
new Int32Array(0),
|
||||
new Uint32Array(0),
|
||||
new Float32Array(0),
|
||||
new Float64Array(0)
|
||||
new Int8Array(),
|
||||
new Uint8Array(),
|
||||
new Uint8ClampedArray(),
|
||||
new Uint16Array(),
|
||||
new Int32Array(),
|
||||
new Uint32Array(),
|
||||
new Float32Array(),
|
||||
new Float64Array()
|
||||
];
|
||||
|
||||
for (const item of typedArrays) {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
"extends": "@sindresorhus/tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"target": "es2016",
|
||||
"target": "es2017",
|
||||
"lib": [
|
||||
"es2016",
|
||||
"es2017.sharedmemory",
|
||||
"es2017",
|
||||
"esnext.asynciterable",
|
||||
"dom"
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue