Skip to content

Commit

Permalink
switch to use tsdx
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolm-kee committed Aug 8, 2019
1 parent 6093fad commit ef8e21d
Show file tree
Hide file tree
Showing 13 changed files with 2,741 additions and 431 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/
dist/
dist/
.rts2_cache_cjs
.rts2_cache_esm
.rts2_cache_umd
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ cache:
yarn: true
directories:
- node_modules
before_deploy:
- cd dist
script:
- yarn test:ci
- yarn build
Expand Down
54 changes: 22 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{
"name": "typesafe-is",
"version": "1.1.2",
"version": "1.1.3",
"description": "Check the type of a value with typescript typeguard",
"main": "index.js",
"main": "dist/index.js",
"module": "dist/typesafe-is.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"keywords": [
"typescript",
"typecheck",
"type guard"
],
"scripts": {
"test": "jest",
"test:ci": "jest --coverage --coverageReporters=text-lcov | coveralls",
"prebuild": "rimraf dist",
"copy": "copy package.json dist && copy README.md dist",
"compile": "tsc --p tsconfig.json",
"build": "npm run compile && npm run copy"
"start": "tsdx watch",
"test": "tsdx test",
"test:ci": "tsdx test --coverage --coverageReporters=text-lcov | coveralls",
"build": "tsdx build"
},
"author": "Malcolm Kee <malcolm.keeweesiong@gmail.com>",
"license": "MIT",
Expand All @@ -26,32 +29,19 @@
"url": "https://github.com/malcolm-kee/typesafe-is/issues"
},
"homepage": "https://github.com/malcolm-kee/typesafe-is#readme",
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"devDependencies": {
"@types/jest": "^24.0.13",
"copy": "^0.3.2",
"coveralls": "^3.0.4",
"jest": "^24.8.0",
"prettier": "^1.15.2",
"rimraf": "^2.6.2",
"ts-jest": "^24.0.2",
"tslint": "^5.17.0",
"typescript": "^3.1.6"
},
"jest": {
"transform": {
"^.+\\.ts$": "ts-jest"
},
"testRegex": "test/.*.(tsx?|jsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"collectCoverageFrom": [
"src/**/*.ts"
]
"husky": "^3.0.3",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1",
"tsdx": "^0.7.2",
"tslib": "^1.10.0",
"typescript": "^3.5.3"
}
}
26 changes: 19 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
export { default as isArray } from './isArray';
export { default as isDefined } from './isDefined';
export { default as isFilledString } from './isFilledString';
export { default as isFunction } from './isFunction';
export { default as isNil } from './isNil';
export { default as isNumber } from './isNumber';
export { default as isString } from './isString';
export const isDefined = <T>(value: T | undefined): value is T =>
typeof value !== 'undefined';

export const isNil = (value: any): value is undefined | null =>
typeof value === 'undefined' || value === null;

export const isNumber = (value: any): value is number => typeof value === 'number';

export const isString = (value: any): value is string => typeof value === 'string';

/**
* the value is a string and is not an empty string ('')
*/
export const isFilledString = (value: any): value is string =>
typeof value === 'string' && value.length > 0;

export const isArray = <T>(value: any): value is Array<T> => Array.isArray(value);

export const isFunction = (value: any): value is Function => typeof value === 'function';
3 changes: 0 additions & 3 deletions src/isArray.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/isDefined.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/isFilledString.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/isFunction.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/isNil.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/isNumber.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/isString.ts

This file was deleted.

13 changes: 8 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"compilerOptions": {
/* Basic Options */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["es6"], /* Specify library files to be included in the compilation. */
"module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["dom"] /* Specify library files to be included in the compilation. */,
"importHelpers": true,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down Expand Up @@ -36,9 +37,11 @@
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
"paths": {
"*": ["src/*", "node_modules/*"]
},
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
Expand Down

0 comments on commit ef8e21d

Please sign in to comment.