This commit is contained in:
Sindre Sorhus 2017-11-06 22:36:51 +07:00
parent 8d8fd2b7e0
commit 9770f66899
4 changed files with 90 additions and 79 deletions

View file

@ -12,6 +12,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"main": "dist/index.js",
"engines": { "engines": {
"node": ">=4" "node": ">=4"
}, },
@ -21,8 +22,6 @@
"test": "npm run lint && npm run build && ava dist/tests", "test": "npm run lint && npm run build && ava dist/tests",
"prepublish": "npm run build && del dist/tests" "prepublish": "npm run build && del dist/tests"
}, },
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [ "files": [
"dist" "dist"
], ],
@ -56,5 +55,6 @@
"tslint": "^5.8.0", "tslint": "^5.8.0",
"tslint-xo": "^0.2.1", "tslint-xo": "^0.2.1",
"typescript": "^2.6.1" "typescript": "^2.6.1"
} },
"types": "dist/index.d.ts"
} }

View file

@ -2,7 +2,7 @@ import * as util from 'util';
const toString = Object.prototype.toString; const toString = Object.prototype.toString;
const getObjectType = (value: any) => toString.call(value).slice(8, -1) as string; 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; const isObjectOfType = (type: string) => (value: any) => getObjectType(value) === type;
function is(value: any) { // tslint:disable-line:only-arrow-functions 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 // 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 // See https://github.com/Microsoft/TypeScript/issues/2536
Object.defineProperties(is, { Object.defineProperties(is, {
class: {value: is.class_}, class: {
function: {value: is.function_}, value: is.class_
null: {value: is.null_} },
function: {
value: is.function_
},
null: {
value: is.null_
}
}); });
export default is; // tslint:disable-line:no-default-export export default is; // tslint:disable-line:no-default-export

View file

@ -5,7 +5,9 @@ import m from '..';
const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8; const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8;
// Currently out of order, see https://github.com/Microsoft/TypeScript/issues/15202 class PromiseSubclassFixture<T> extends Promise<T> {} // Currently not working. See https://github.com/Microsoft/TypeScript/issues/15202
// `class PromiseSubclassFixture<T> extends Promise<T> {}`
class ErrorSubclassFixture extends Error {} class ErrorSubclassFixture extends Error {}
const document = jsdom(); const document = jsdom();

View file

@ -10,8 +10,11 @@
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,
"outDir": "dist", "outDir": "dist",
"removeComments": true,
"lib": [ "lib": [
"es2015", "dom", "scripthost" "es2015",
"dom",
"scripthost"
] ]
} }
} }