nv-typeof
v1.0.8
Published
typeof ======================= - same as typeof , mode types suported
Downloads
2
Readme
nv-typeof
- same as typeof , mode types suported
install
- npm install typeof
splitted
usage
const tof = require("nv-typeof");
> tof
[Function: tname] {
TNAMES: [
'u', 'n', 't', 'f',
'num', 'str', 'bi', 'gsym',
'lsym', 'dt', 'rgx', 'ary',
'dict', 'st', 'mp', 'ab',
'dv', 'u8a', 'u8ca', 'i8a',
'u16a', 'i16a', 'u32a', 'i32a',
'u64a', 'i64a', 'f32a', 'f64a',
'eval_err', 'rng_err', 'ref_err', 'typ_err',
'uri_err', 'agg_errs', 'other_err', 'wkst',
'wkmp', 'wkref', 'truo', 'flso',
'numo', 'stro', 'prms', 'iter',
'sg', 'ag', 'cls', 'sfunc',
'afunc', 'sgen', 'agen', 'slmbd',
'almbd', 'smthd', 'amthd', 'mthd_sgen',
'mthd_agen', 'getter', 'setter', 'other'
],
creat_handles: [Function: creat_handles],
show_switch_code_tmpl: [Function (anonymous)]
}
>
example
test all supported types:
class Cls {
#v;
smthd() {}
async amthd() {}
*mthd_sgen() {}
async* mthd_agen() {}
get v() {return(this.#v);}
set v(val) {this.#v = val;}
};
const PROTO = Cls.prototype;
const GETTER = Object.getOwnPropertyDescriptors(Cls.prototype).v.get;
const SETTER = Object.getOwnPropertyDescriptors(Cls.prototype).v.set;
const AB = new ArrayBuffer(0);
let SAB;
if(globalThis.SharedArrayBuffer) {
SAB = new SharedArrayBuffer(0);
} else {
SAB = new ArrayBuffer(0);
}
const EVEL_ERR = new EvalError();
const RNG_ERR = new RangeError();
const REF_ERR = new ReferenceError();
const TYP_ERR = new TypeError();
const URI_ERR = new URIError();
const OTHER_ERR = new Error();
const AGG_ERRS = new AggregateError([EVEL_ERR,RNG_ERR,REF_ERR,TYP_ERR,URI_ERR,OTHER_ERR]);
const SGEN = function*() {};
const AGEN = async function*() {};
const SFUNC = function() {};
const AFUNC = async function() {};
const EXAMPLES = [
undefined,null,true,false,
0,'',0n,
Symbol(),Symbol.for(),
new Date(0),/^$/,
[],{},new Set(),new Map(),
AB,SAB,new DataView(AB),
new Uint8Array(0),new Uint8ClampedArray(0),new Int8Array(0),new Uint16Array(0),new Int16Array(0),new Uint32Array(0),new Int32Array(0),new BigUint64Array(0),new BigInt64Array(0),
new Float32Array(0),new Float64Array(0),
EVEL_ERR,RNG_ERR,REF_ERR,TYP_ERR,URI_ERR,AGG_ERRS,OTHER_ERR,
new WeakSet(), new WeakMap(),new WeakRef(AB),
new Boolean(true),new Boolean(false),new Number(0),new String(''),
new Promise((rs,rj)=>{}),(new Map()).entries(), SGEN(),AGEN(),
Cls,SFUNC,AFUNC,SGEN,AGEN,()=>{},async()=>{},
PROTO.smthd,PROTO.amthd,PROTO.mthd_sgen,PROTO.mthd_agen,
GETTER ,SETTER
];
/*
[
undefined,
null,
true,
false,
0,
'',
0n,
Symbol(),
Symbol(undefined),
1970-01-01T00:00:00.000Z,
/^$/,
[],
{},
Set(0) {},
Map(0) {},
ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 },
SharedArrayBuffer { [Uint8Contents]: <>, byteLength: 0 },
DataView {
byteLength: 0,
byteOffset: 0,
buffer: ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 }
},
Uint8Array(0) [],
Uint8ClampedArray(0) [],
Int8Array(0) [],
Uint16Array(0) [],
Int16Array(0) [],
Uint32Array(0) [],
Int32Array(0) [],
BigUint64Array(0) [],
BigInt64Array(0) [],
Float32Array(0) [],
Float64Array(0) [],
EvalError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:22:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
RangeError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:23:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
ReferenceError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:24:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
TypeError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:25:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
URIError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:26:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
AggregateError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:28:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22) {
[errors]: [
EvalError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:22:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
RangeError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:23:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
ReferenceError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:24:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
TypeError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:25:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
URIError
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:26:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
Error
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:27:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22)
]
},
Error
at Object.<anonymous> (/mnt/sda3/NV6-/nvfac/pkgs/cmmn-dep/nv-facutil-dflt-val/index.js:27:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at REPL1:1:3
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22),
WeakSet { <items unknown> },
WeakMap { <items unknown> },
WeakRef {},
[Boolean: true],
[Boolean: false],
[Number: 0],
[String: ''],
Promise {
<pending>,
[Symbol(async_id_symbol)]: 44,
[Symbol(trigger_async_id_symbol)]: 6
},
[Map Entries] { },
Object [Generator] {},
Object [AsyncGenerator] {},
[class Cls],
[Function: SFUNC],
[AsyncFunction: AFUNC],
[GeneratorFunction: SGEN],
[AsyncGeneratorFunction: AGEN],
[Function (anonymous)],
[AsyncFunction (anonymous)],
[Function: smthd],
[AsyncFunction: amthd],
[GeneratorFunction: mthd_sgen],
[AsyncGeneratorFunction: mthd_agen],
[Function: get v],
[Function: set v]
]
*/
for(var o of EXAMPLES) {console.log(tof(o))}
/*
u
n
t
f
num
str
bi
lsym
gsym
dt
rgx
ary
dict
st
mp
ab
ab
dv
u8a
u8ca
i8a
u16a
i16a
u32a
i32a
u64a
i64a
f32a
f64a
eval_err
rng_err
ref_err
typ_err
uri_err
agg_err
other_err
wkst
wkmp
wkref
truo
flso
numo
stro
prms
iter
sg
ag
cls
sfunc
amthd
agen
sgen
slmbd
almbd
smthd
amthd
mthd_agen
mthd_sgen
getter
setter
*/
handle dict
> tof.creat_handles()
HandleDict {
u: [Function: DFLT_HANDLE],
n: [Function: DFLT_HANDLE],
t: [Function: DFLT_HANDLE],
f: [Function: DFLT_HANDLE],
num: [Function: DFLT_HANDLE],
str: [Function: DFLT_HANDLE],
bi: [Function: DFLT_HANDLE],
gsym: [Function: DFLT_HANDLE],
lsym: [Function: DFLT_HANDLE],
dt: [Function: DFLT_HANDLE],
rgx: [Function: DFLT_HANDLE],
ary: [Function: DFLT_HANDLE],
dict: [Function: DFLT_HANDLE],
st: [Function: DFLT_HANDLE],
mp: [Function: DFLT_HANDLE],
ab: [Function: DFLT_HANDLE],
dv: [Function: DFLT_HANDLE],
u8a: [Function: DFLT_HANDLE],
u8ca: [Function: DFLT_HANDLE],
i8a: [Function: DFLT_HANDLE],
u16a: [Function: DFLT_HANDLE],
i16a: [Function: DFLT_HANDLE],
u32a: [Function: DFLT_HANDLE],
i32a: [Function: DFLT_HANDLE],
u64a: [Function: DFLT_HANDLE],
i64a: [Function: DFLT_HANDLE],
f32a: [Function: DFLT_HANDLE],
f64a: [Function: DFLT_HANDLE],
eval_err: [Function: DFLT_HANDLE],
rng_err: [Function: DFLT_HANDLE],
ref_err: [Function: DFLT_HANDLE],
typ_err: [Function: DFLT_HANDLE],
uri_err: [Function: DFLT_HANDLE],
agg_errs: [Function: DFLT_HANDLE],
other_err: [Function: DFLT_HANDLE],
wkst: [Function: DFLT_HANDLE],
wkmp: [Function: DFLT_HANDLE],
wkref: [Function: DFLT_HANDLE],
truo: [Function: DFLT_HANDLE],
flso: [Function: DFLT_HANDLE],
numo: [Function: DFLT_HANDLE],
stro: [Function: DFLT_HANDLE],
prms: [Function: DFLT_HANDLE],
iter: [Function: DFLT_HANDLE],
sg: [Function: DFLT_HANDLE],
ag: [Function: DFLT_HANDLE],
cls: [Function: DFLT_HANDLE],
sfunc: [Function: DFLT_HANDLE],
afunc: [Function: DFLT_HANDLE],
sgen: [Function: DFLT_HANDLE],
agen: [Function: DFLT_HANDLE],
slmbd: [Function: DFLT_HANDLE],
almbd: [Function: DFLT_HANDLE],
smthd: [Function: DFLT_HANDLE],
amthd: [Function: DFLT_HANDLE],
mthd_sgen: [Function: DFLT_HANDLE],
mthd_agen: [Function: DFLT_HANDLE],
getter: [Function: DFLT_HANDLE],
setter: [Function: DFLT_HANDLE],
other: [Function: DFLT_HANDLE]
}
>
show switch code tmpl
tof.show_switch_code_tmpl()
const typof = require("typeof");
var nm = typof(o)
switch(nm){
case("u") : {
break;
}
case("n") : {
break;
}
case("t") : {
break;
}
case("f") : {
break;
}
case("num") : {
break;
}
case("str") : {
break;
}
case("bi") : {
break;
}
case("gsym") : {
break;
}
case("lsym") : {
break;
}
case("dt") : {
break;
}
case("rgx") : {
break;
}
case("ary") : {
break;
}
case("dict") : {
break;
}
case("st") : {
break;
}
case("mp") : {
break;
}
case("ab") : {
break;
}
case("dv") : {
break;
}
case("u8a") : {
break;
}
case("u8ca") : {
break;
}
case("i8a") : {
break;
}
case("u16a") : {
break;
}
case("i16a") : {
break;
}
case("u32a") : {
break;
}
case("i32a") : {
break;
}
case("u64a") : {
break;
}
case("i64a") : {
break;
}
case("f32a") : {
break;
}
case("f64a") : {
break;
}
case("eval_err") : {
break;
}
case("rng_err") : {
break;
}
case("ref_err") : {
break;
}
case("typ_err") : {
break;
}
case("uri_err") : {
break;
}
case("agg_errs") : {
break;
}
case("other_err") : {
break;
}
case("wkst") : {
break;
}
case("wkmp") : {
break;
}
case("wkref") : {
break;
}
case("truo") : {
break;
}
case("flso") : {
break;
}
case("numo") : {
break;
}
case("stro") : {
break;
}
case("prms") : {
break;
}
case("iter") : {
break;
}
case("sg") : {
break;
}
case("ag") : {
break;
}
case("cls") : {
break;
}
case("sfunc") : {
break;
}
case("afunc") : {
break;
}
case("sgen") : {
break;
}
case("agen") : {
break;
}
case("slmbd") : {
break;
}
case("almbd") : {
break;
}
case("smthd") : {
break;
}
case("amthd") : {
break;
}
case("mthd_sgen") : {
break;
}
case("mthd_agen") : {
break;
}
case("getter") : {
break;
}
case("setter") : {
break;
}
default: {
}
}
METHODS
APIS
LICENSE
- ISC