mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
more playing with patterns (need more testing)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
49d8795cb1
commit
aa93295866
22
diff.js
22
diff.js
@ -342,13 +342,31 @@ module.STRING =
|
|||||||
// NUMBER(func)
|
// NUMBER(func)
|
||||||
// -> pattern
|
// -> pattern
|
||||||
//
|
//
|
||||||
// XXX support range checking, ...
|
// XXX TEST...
|
||||||
var NUMBER =
|
var NUMBER =
|
||||||
module.NUMBER =
|
module.NUMBER =
|
||||||
makeCIPattern('NUMBER',
|
makeCIPattern('NUMBER',
|
||||||
function(obj, cmp){
|
function(obj, cmp){
|
||||||
// XXX do the .value test....
|
// XXX do the .value test....
|
||||||
return obj === NUMBER || typeof(obj) == typeof(123) },
|
return obj === NUMBER
|
||||||
|
|| (typeof(obj) == typeof(123)
|
||||||
|
&& (this.value.length == 1 ?
|
||||||
|
this.value[0] == obj
|
||||||
|
// min/max...
|
||||||
|
: this.value.length == 2 ?
|
||||||
|
this.value[0] <= obj
|
||||||
|
&& this.value[1] > obj
|
||||||
|
// min/max/step...
|
||||||
|
: this.value.length == 3 ?
|
||||||
|
this.value[0] <= obj
|
||||||
|
&& this.value[1] > obj
|
||||||
|
&& (obj + (this.value[0] % this.value[2])) % this.value[2]
|
||||||
|
: this.value[0] instanceof Function ?
|
||||||
|
this.value[0](obj)
|
||||||
|
// pattern...
|
||||||
|
: this.value[0] != null ?
|
||||||
|
cmp(this.value[0], obj)
|
||||||
|
: true )) },
|
||||||
function(...value){ this.value = value })
|
function(...value){ this.value = value })
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user