@typen/num-strict
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,23 +5,11 @@ 'use strict'; | ||
var enumDataTypes = require('@typen/enum-data-types'); | ||
var typ = require('@typen/typ'); | ||
// Angular 4.3 | ||
const isNumeric = x => !isNaN(x - parseFloat(x)); | ||
// from x => typeof x | ||
const NUM = 'number'; | ||
const STR = 'string'; | ||
const OBJ = 'object'; | ||
const OptS = Object.prototype.toString; | ||
/** | ||
* const rxObj = /^\[object (.*)]$/ | ||
* Equivalent to: Object.prototype.stringify.call(o).match(rxObj)[1] | ||
* @param {*} o | ||
* @return {string} | ||
*/ | ||
const typ = o => OptS.call(o).slice(8, -1); | ||
const inferType = x => { | ||
const t = typeof x; | ||
return t === STR ? isNumeric(x) ? NUM : STR : t === OBJ ? typ(x) : t; | ||
return t === enumDataTypes.STR ? isNumeric(x) ? enumDataTypes.NUM : enumDataTypes.STR : t === enumDataTypes.OBJ ? typ.typ(x) : t; | ||
}; | ||
@@ -28,0 +16,0 @@ |
@@ -0,19 +1,7 @@ | ||
import { STR, NUM, OBJ } from '@typen/enum-data-types'; | ||
import { typ } from '@typen/typ'; | ||
// Angular 4.3 | ||
const isNumeric = x => !isNaN(x - parseFloat(x)); | ||
// from x => typeof x | ||
const NUM = 'number'; | ||
const STR = 'string'; | ||
const OBJ = 'object'; | ||
const OptS = Object.prototype.toString; | ||
/** | ||
* const rxObj = /^\[object (.*)]$/ | ||
* Equivalent to: Object.prototype.stringify.call(o).match(rxObj)[1] | ||
* @param {*} o | ||
* @return {string} | ||
*/ | ||
const typ = o => OptS.call(o).slice(8, -1); | ||
const inferType = x => { | ||
@@ -20,0 +8,0 @@ const t = typeof x; |
{ | ||
"name": "@typen/num-strict", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A type cheker", | ||
@@ -17,2 +17,6 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"dependencies": { | ||
"@typen/enum-data-types": "^0.0.2", | ||
"@typen/typ": "^0.0.2" | ||
}, | ||
"repository": { | ||
@@ -33,3 +37,3 @@ "type": "git", | ||
"homepage": "https://github.com/hoyeungw/typen#readme", | ||
"gitHead": "d0fd55ecea305361b1ff7dd19e2ff311f7b46052" | ||
"gitHead": "9b4e2ddb145e45ce721bb778b01ba802ff1d763c" | ||
} |
4543
2
38
+ Added@typen/typ@^0.0.2
+ Added@typen/enum-data-types@0.0.2(transitive)
+ Added@typen/typ@0.0.2(transitive)