Skip to content
Open

LEX fix #1187

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,12 @@
while(l-- > 0){ s += c.charAt(Math.floor(Math.random() * c.length)) }
return s;
}
String.match = function(t, o){ var tmp, u;
if('string' !== typeof t){ return false }
if('string' == typeof o){ o = {'=': o} }
o = o || {};
tmp = (o['='] || o['*'] || o['>'] || o['<']);
if(t === tmp){ return true }
if(u !== o['=']){ return false }
tmp = (o['*'] || o['>']);
if(t.slice(0, (tmp||'').length) === tmp){ return true }
if(u !== o['*']){ return false }
if(u !== o['>'] && u !== o['<']){
return (t >= o['>'] && t <= o['<'])? true : false;
}
if(u !== o['>'] && t >= o['>']){ return true }
if(u !== o['<'] && t <= o['<']){ return true }
return false;
}
String.match = (t, o) =>
'string' === typeof t &&
((t === o['='] ?? o) ||
(t.slice(0, o['*']?.length ?? 0) === o['*'] &&
t >= (o['>'] ?? t) &&
t <= (o['<'] ?? t)));
String.hash = function(s, c){ // via SO
if(typeof s !== 'string'){ return }
c = c || 0; // CPU schedule hashing by
Expand Down Expand Up @@ -2226,4 +2215,4 @@
var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_has = obj.has, obj_empty = obj.empty, obj_put = obj.put, obj_map = obj.map, obj_copy = obj.copy;
var u;
Type.graph = Type.graph || Graph;
}());
}());
25 changes: 8 additions & 17 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@
while(l > 0){ s += c.charAt(Math.floor(Math.random() * c.length)); l-- }
return s;
}
Type.text.match = Type.text.match || function(t, o){ var tmp, u; DEP('text.match');
if('string' !== typeof t){ return false }
if('string' == typeof o){ o = {'=': o} }
o = o || {};
tmp = (o['='] || o['*'] || o['>'] || o['<']);
if(t === tmp){ return true }
if(u !== o['=']){ return false }
tmp = (o['*'] || o['>'] || o['<']);
if(t.slice(0, (tmp||'').length) === tmp){ return true }
if(u !== o['*']){ return false }
if(u !== o['>'] && u !== o['<']){
return (t >= o['>'] && t <= o['<'])? true : false;
}
if(u !== o['>'] && t >= o['>']){ return true }
if(u !== o['<'] && t <= o['<']){ return true }
return false;
Type.text.match = Type.text.match || (t, o) => {
DEP('text.match');
return 'string' === typeof t &&
((t === o['='] ?? o) ||
(t.slice(0, o['*']?.length ?? 0) === o['*'] &&
t >= (o['>'] ?? t) &&
t <= (o['<'] ?? t)));
}
Type.text.hash = Type.text.hash || function(s, c){ // via SO
DEP('text.hash');
Expand Down Expand Up @@ -448,4 +439,4 @@
var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_has = obj.has, obj_empty = obj.empty, obj_put = obj.put, obj_map = obj.map, obj_copy = obj.copy;
var u;
Type.graph = Type.graph || Graph;
}());
}());
25 changes: 7 additions & 18 deletions src/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,12 @@ String.random = function(l, c){
while(l-- > 0){ s += c.charAt(Math.floor(Math.random() * c.length)) }
return s;
}
String.match = function(t, o){ var tmp, u;
if('string' !== typeof t){ return false }
if('string' == typeof o){ o = {'=': o} }
o = o || {};
tmp = (o['='] || o['*'] || o['>'] || o['<']);
if(t === tmp){ return true }
if(u !== o['=']){ return false }
tmp = (o['*'] || o['>']);
if(t.slice(0, (tmp||'').length) === tmp){ return true }
if(u !== o['*']){ return false }
if(u !== o['>'] && u !== o['<']){
return (t >= o['>'] && t <= o['<'])? true : false;
}
if(u !== o['>'] && t >= o['>']){ return true }
if(u !== o['<'] && t <= o['<']){ return true }
return false;
}
String.match = (t, o) =>
'string' === typeof t &&
((t === o['='] ?? o) ||
(t.slice(0, o['*']?.length ?? 0) === o['*'] &&
t >= (o['>'] ?? t) &&
t <= (o['<'] ?? t)));
String.hash = function(s, c){ // via SO
if(typeof s !== 'string'){ return }
c = c || 0; // CPU schedule hashing by
Expand Down Expand Up @@ -75,4 +64,4 @@ Object.keys = Object.keys || function(o){
} e && e(r);
}())})();
}());