Catalog npm
PACKAGE EXPLORERView in registry

0model

npm

Lightweight module for data control

datajustdoitstrong typingdata-modelmodelvalidatevalidation
Versions collected18
Direct dependencies0From release 0.4.2
Last observed20 Oct, 17:43 UTC

README

Current package documentation

Codacy

npm -g install 0model

  • Coverage: +
  • Browser: +

Browser

  • Include: //raw.githack.com/Daeren/0model/master/index.js

Global var: zm

Examples

var zm = require("0model");


zm(" D ").string().get().trim();            // <-- "D"
zm(" 13.").to.int().it.is.required();       // <-- true

zm({x: 1, y: 2}).to.have("x", "z");         // <-- false
zm({}).it.is.empty();                       // <-- true


zm("[1,2]").to.json().get();                // <-- [1, 2]
zm("[1,").to.json().to.string().get();      // <-- ''
zm("[1,").json().string().get();            // <-- ''

zm(5.9).int().str() + 10;                   // <-- '510'
zm(5.9).to.integer() + " num";              // <-- '5 num'
zm(zm('d0' / 1)).empty();                   // <-- true


zm([1, 2, 3]).set(x => x.reduce((a, b) => a + b)).get(console.log);
zm(3.14159).set(x => x.toFixed(0)).str().get(console.log);


zm("hello 2 world").to.string().then.remove(/\d+/).it.is.required();
zm("hello 2 world").to.string().then.remove(/\d+/).get();
zm("hello 2 world").to.string().then.remove(d => d.substr(2)) + "!";

Instance

AttributeTypeNote
-
to, then, is, itobjectthis
-
setfunction(v)return: this
getfunction([callback])return: current value
-
lastError-
value-current value
[T]
bool, booleanfunction(true, on, yes, 1) = true
str, stringfunction(NaN, null, undefined, []) = ""
int, integerfunction(radix)
float, numberfunction
-
datefunction
symbolfunction
-
table, hashTablefunction(notParse)
arrayfunction(notParse)
jsonfunction
[M]
removefunction(t)t: string, regEx (string), function(elem)
absfunction
clampfunction(min, max)
[V]
requiredfunctionfalse: NaN, [], null, undefined, "", Invalid Date, {}
emptyfunctiontrue: NaN, [], null, undefined, "", Invalid Date, {}
has, havefunction(...)for: string, array, object

License

MIT


@ Daeren

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 18

Collected releases
VersionPublishedDirect dependenciesOpen version
0.4.2Registry latest19 Oct 20160
0.4.119 Oct 20160
0.3.119 Oct 20160
0.3.019 Oct 20160
0.2.019 Oct 20160
0.1.019 Oct 20160
0.0.123 Dec 20150
0.0.112 Dec 20150
0.0.101 Dec 20150
0.0.91 Dec 20150
0.0.81 Dec 20150
0.0.71 Dec 20150
0.0.61 Dec 20150
0.0.51 Dec 20150
0.0.41 Dec 20150
0.0.31 Dec 20150
0.0.21 Dec 20150
0.0.13 Mar 20151

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
daeren/0model

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:1c1d9390c476b5f034377d1af3065787549a634f5b462aab395fbb5448dcdbfc