diff --git a/.travis.yml b/.travis.yml index 2ae9d62..f3fa8cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,3 @@ language: node_js node_js: - '10' - '8' - - '6' diff --git a/package.json b/package.json index f45f2f3..e34361a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/source/index.ts b/source/index.ts index 64943ab..9f9886e 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,5 +1,4 @@ -/// -/// +/// /// /// @@ -145,7 +144,7 @@ is.nativePromise = (value: unknown): value is Promise => const hasPromiseAPI = (value: unknown): value is Promise => !is.null_(value) && isObject(value) as unknown && - is.function_((value as Promise).then) && + is.function_((value as Promise).then) && // eslint-disable-line promise/prefer-await-to-then is.function_((value as Promise).catch); is.promise = (value: unknown): value is Promise => is.nativePromise(value) || hasPromiseAPI(value); @@ -180,7 +179,7 @@ is.arrayBuffer = isObjectOfType(TypeName.ArrayBuffer); is.sharedArrayBuffer = isObjectOfType(TypeName.SharedArrayBuffer); is.dataView = isObjectOfType(TypeName.DataView); -is.directInstanceOf = (instance: unknown, klass: Class): instance is T => Object.getPrototypeOf(instance) === klass.prototype; +is.directInstanceOf = (instance: unknown, class_: Class): instance is T => Object.getPrototypeOf(instance) === class_.prototype; is.urlInstance = (value: unknown): value is URL => isObjectOfType(TypeName.URL)(value); is.urlString = (value: unknown): value is string => { diff --git a/test/test.ts b/test/test.ts index d25d28b..f34e245 100644 --- a/test/test.ts +++ b/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 extends Promise {} @@ -223,55 +222,55 @@ const types = new Map([ ['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) { diff --git a/tsconfig.json b/tsconfig.json index 058d3a0..c76ee17 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,9 @@ "extends": "@sindresorhus/tsconfig", "compilerOptions": { "outDir": "dist", - "target": "es2016", + "target": "es2017", "lib": [ - "es2016", - "es2017.sharedmemory", + "es2017", "esnext.asynciterable", "dom" ]