From 9770f6689946dffd72b3ba0b212c609418827c3f Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 6 Nov 2017 22:36:51 +0700 Subject: [PATCH] Cleanup --- package.json | 116 +++++++++++++++++++++---------------------- source/index.ts | 16 ++++-- source/tests/test.ts | 4 +- tsconfig.json | 33 ++++++------ 4 files changed, 90 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index 459679d..22e3e1d 100644 --- a/package.json +++ b/package.json @@ -1,60 +1,60 @@ { - "name": "@sindresorhus/is", - "version": "0.4.0", - "description": "Type check values: `is.string('🦄') //=> true`", - "license": "MIT", - "repository": "sindresorhus/is", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "lint": "tslint --project .", - "build": "tsc", - "test": "npm run lint && npm run build && ava dist/tests", - "prepublish": "npm run build && del dist/tests" - }, - "main": "dist/index.js", - "types": "dist/index.d.ts", - "files": [ - "dist" - ], - "keywords": [ - "type", - "types", - "is", - "check", - "checking", - "validate", - "validation", - "utility", - "util", - "typeof", - "instanceof", - "object", - "assert", - "assertion", - "test", - "kind", - "primitive", - "verify", - "compare" - ], - "devDependencies": { - "@types/jsdom": "^2.0.31", - "@types/node": "^8.0.47", - "ava": "*", - "del-cli": "^1.1.0", - "jsdom": "^9.12.0", - "tslint": "^5.8.0", - "tslint-xo": "^0.2.1", - "typescript": "^2.6.1" - } + "name": "@sindresorhus/is", + "version": "0.4.0", + "description": "Type check values: `is.string('🦄') //=> true`", + "license": "MIT", + "repository": "sindresorhus/is", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "publishConfig": { + "access": "public" + }, + "main": "dist/index.js", + "engines": { + "node": ">=4" + }, + "scripts": { + "lint": "tslint --project .", + "build": "tsc", + "test": "npm run lint && npm run build && ava dist/tests", + "prepublish": "npm run build && del dist/tests" + }, + "files": [ + "dist" + ], + "keywords": [ + "type", + "types", + "is", + "check", + "checking", + "validate", + "validation", + "utility", + "util", + "typeof", + "instanceof", + "object", + "assert", + "assertion", + "test", + "kind", + "primitive", + "verify", + "compare" + ], + "devDependencies": { + "@types/jsdom": "^2.0.31", + "@types/node": "^8.0.47", + "ava": "*", + "del-cli": "^1.1.0", + "jsdom": "^9.12.0", + "tslint": "^5.8.0", + "tslint-xo": "^0.2.1", + "typescript": "^2.6.1" + }, + "types": "dist/index.d.ts" } diff --git a/source/index.ts b/source/index.ts index ce877eb..3bf75ff 100644 --- a/source/index.ts +++ b/source/index.ts @@ -2,7 +2,7 @@ import * as util from 'util'; const toString = Object.prototype.toString; const getObjectType = (value: any) => toString.call(value).slice(8, -1) as string; -const isOfType = (type: string) => (value: any) => typeof value === type; // tslint:disable-line +const isOfType = (type: string) => (value: any) => typeof value === type; // tslint:disable-line:strict-type-predicates const isObjectOfType = (type: string) => (value: any) => getObjectType(value) === type; function is(value: any) { // tslint:disable-line:only-arrow-functions @@ -232,12 +232,18 @@ namespace is { // tslint:disable-line:no-namespace // tslint:enable:only-arrow-functions no-function-expression } -// Some few keywords are reserved, but we'll populate them for the node-folks +// Some few keywords are reserved, but we'll populate them for Node.js users // See https://github.com/Microsoft/TypeScript/issues/2536 Object.defineProperties(is, { - class: {value: is.class_}, - function: {value: is.function_}, - null: {value: is.null_} + class: { + value: is.class_ + }, + function: { + value: is.function_ + }, + null: { + value: is.null_ + } }); export default is; // tslint:disable-line:no-default-export diff --git a/source/tests/test.ts b/source/tests/test.ts index 54f9041..6e9246a 100644 --- a/source/tests/test.ts +++ b/source/tests/test.ts @@ -5,7 +5,9 @@ import m from '..'; const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8; -// Currently out of order, see https://github.com/Microsoft/TypeScript/issues/15202 class PromiseSubclassFixture extends Promise {} +// Currently not working. See https://github.com/Microsoft/TypeScript/issues/15202 +// `class PromiseSubclassFixture extends Promise {}` + class ErrorSubclassFixture extends Error {} const document = jsdom(); diff --git a/tsconfig.json b/tsconfig.json index b3d8332..7448590 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,20 @@ { - "compileOnSave": true, - "compilerOptions": { - /* es2015 requires moduleResolution and module to be set, - see https://github.com/Microsoft/TypeScript/issues/8189 */ - "target": "es2015", - "moduleResolution": "node", - "module": "none", - "strict": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": [ - "es2015", "dom", "scripthost" - ] - } + "compileOnSave": true, + "compilerOptions": { + /* es2015 requires moduleResolution and module to be set, + see https://github.com/Microsoft/TypeScript/issues/8189 */ + "target": "es2015", + "moduleResolution": "node", + "module": "none", + "strict": true, + "declaration": true, + "sourceMap": true, + "outDir": "dist", + "removeComments": true, + "lib": [ + "es2015", + "dom", + "scripthost" + ] + } }