Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

functional-lite

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functional-lite - npm Package Compare versions

Comparing version 0.2.4 to 0.2.6

64

index.js

@@ -5,4 +5,4 @@

/*
* @version 0.2.4
* @date 2014-06-10
* @version 0.2.6
* @date 2014-06-17
* @stability 2 - Unstable

@@ -19,8 +19,8 @@ * @author Lauri Rooden <lauri@rooden.ee>

, O = Object
, sl = F.call.bind(A.slice)
, cs = []
, hasOwn = O[P].hasOwnProperty
, slice = F.call.bind(A.slice)
, constructFns = []
// Function extensions

@@ -31,12 +31,12 @@ // -------------------

F.construct = function(a) {
/*
* bind version have bad performance and memory consumption
* return new(F.bind.apply(this, A.concat.apply([null], a)))
*/
var l = a.length
return l ? (cs[l] || (cs[l] = Fn("t a->new t(a["+O.keys(sl(a)).join("],a[")+"])")))(this, a) : new this
// bind version have bad performance and memory consumption
// return new(F.bind.apply(this, A.concat.apply([null], a)))
var len = a.length
return len ?
(constructFns[len] || (constructFns[len] = Fn("t a->new t(a["+O.keys(slice(a)).join("],a[")+"])")))(this, a) :
new this
}
F.partial = function() {
var self = this, a = sl(arguments)
var self = this, a = slice(arguments)
return function() {return self.apply(this, a.concat.apply(a, arguments))}

@@ -67,3 +67,3 @@ }

return function(o) {
var r, s = this, a = sl(arguments)
var r, s = this, a = slice(arguments)
if (typeof o == "object") for (r in o) {

@@ -85,3 +85,3 @@ a[0] = r

, i = !!instance || this instanceof f
, k = keyFn ? keyFn.apply(self, a) : i + ":" + a.length + ":" + sl(a)
, k = keyFn ? keyFn.apply(self, a) : i + ":" + a.length + ":" + slice(a)

@@ -113,6 +113,6 @@ return k in c ? c[k] : (c[k] = i ? self.construct(a) : self.apply(this, a))

// Time to live - Run *fun* if Function not called on time
F.ttl = function(ms, fun) {
// Time to live - Run *onTimeout* if Function not called on time
F.ttl = function(ms, onTimeout) {
var self = this
, tick = setTimeout(function(){ms=0;fun&&fun()}, ms)
, tick = setTimeout(function(){ms=0;onTimeout&&onTimeout()}, ms)
return function() {

@@ -126,3 +126,4 @@ clearTimeout(tick)

F.once = function(ms) {
var tick, args, self = this
var tick, args
, self = this
return function() {

@@ -137,3 +138,4 @@ clearTimeout(tick)

F.rate = function(ms, last_call) {
var tick, args, self = this, next = 0
var tick, args
, self = this, next = 0
return function() {

@@ -155,3 +157,3 @@ var now = +new Date()

O.each = function(obj, fn, scope, key) {
if (obj) for (key in obj) obj.hasOwnProperty(key) && fn.call(scope, obj[key], key, obj)
if (obj) for (key in obj) hasOwn.call(obj, key) && fn.call(scope, obj[key], key, obj)
}

@@ -162,4 +164,4 @@

O.merge = function(target, source) {
for (var k, i = 1; source = arguments[i++];)
for (k in source) if (source.hasOwnProperty(k)) target[k] = source[k]
for (var key, i = 1; source = arguments[i++];)
for (key in source) if (hasOwn.call(source, key)) target[key] = source[key]
return target

@@ -179,3 +181,3 @@ }

temp = {}
for (key in source) if (source.hasOwnProperty(key))
for (key in source) if (hasOwn.call(source, key))
temp[key] = O.clone(source[key])

@@ -191,9 +193,9 @@ source = temp

for (key in source) if (source.hasOwnProperty(key) && target[key] !== source[key]) {
for (key in source) if (hasOwn.call(source, key) && target[key] !== source[key]) {
val = source[key]
changed.push(path+key)
changed.push(path + key)
if (val === null) delete target[key]
else if (isObject(val)) {
if (!isObject(target[key])) target[key] = {}
O.deepMerge(target[key], val, path+key+".", changed)
O.deepMerge(target[key], val, path + key + ".", changed)
}

@@ -224,7 +226,7 @@ else target[key] = val

var arr = this
, l = arr.length
, o = sl(arguments)
, len = arr.length
, o = slice(arguments)
, lastId = -1
for (;l--;) if (~o.indexOf(arr[l])) arr.splice(lastId = l, 1)
for (;len--;) if (~o.indexOf(arr[len])) arr.splice(lastId = len, 1)
return lastId

@@ -273,4 +275,4 @@ }

body = arr.pop()
args = arr.pop().match(/\w+/g)||""
arr.length && arr.push("(function("+args+"){return("+body+")})")
args = arr.pop().match(/\w+/g) || ""
if (arr.length) arr.push("(function("+args+"){return("+body+")})")
}

@@ -277,0 +279,0 @@ return new Function(args, "return(" + body + ")")

@@ -1,6 +0,6 @@

!function(q){function m(a){var b="_",c=a;for(a=a.split("->");1<a.length;)c=a.pop(),b=a.pop().match(/\w+/g)||"",a.length&&a.push("(function("+b+"){return("+c+")})");return new Function(b,"return("+c+")")}var h=Array.prototype,k=Function.prototype,n=String.prototype,f=Object,l=k.call.bind(h.slice),p=[];k.construct=function(a){var b=a.length;return b?(p[b]||(p[b]=m("t a->new t(a["+f.keys(l(a)).join("],a[")+"])")))(this,a):new this};k.partial=function(){var a=this,b=l(arguments);return function(){return a.apply(this,
b.concat.apply(b,arguments))}};k.byWords=function(a,b){var c=this;return function(){var d=this,e=d,g=arguments;(g[a|=0]||"").replace(b||/\S+/g,function(b){g[a]=b;e=c.apply(d,g)});return e}};k.byKeyVal=function(){var a=this;return function(b){var c,d=l(arguments);if("object"==typeof b)for(c in b)d[0]=c,d[1]=b[c],c=a.apply(this,d);else c=a.apply(this,d);return c}};k.cache=function(a,b,c){var d=this,e=c||{},g=function(){var c=arguments,f=!!a||this instanceof g,h=b?b.apply(d,c):f+":"+c.length+":"+l(c);
return h in e?e[h]:e[h]=f?d.construct(c):d.apply(this,c)};g.origin=d;g.cached=e;g.extend=function(){return d.extend.apply(d,arguments).cache(a,b,c)};g.prototype=d.prototype;return g};k.extend=function(){function a(){return c.apply(this,arguments)}var b,c=this,d=0;for(a.prototype=f.create(c.prototype);b=arguments[d++];)f.merge(a.prototype,b);return a.prototype.constructor=a};k.ttl=function(a,b){var c=this,d=setTimeout(function(){a=0;b&&b()},a);return function(){clearTimeout(d);a&&c.apply(null,arguments)}};
k.once=function(a){var b,c,d=this;return function(){clearTimeout(b);c=arguments;b=setTimeout(function(){d.apply(null,c)},a)}};k.rate=function(a,b){var c,d,e=this,g=0;return function(){var f=+new Date;clearTimeout(c);f>g?(g=f+a,e.apply(null,arguments)):b&&(d=arguments,c=setTimeout(function(){e.apply(null,d)},g-f))}};f.each=function(a,b,c,d){if(a)for(d in a)a.hasOwnProperty(d)&&b.call(c,a[d],d,a)};f.merge=function(a,b){for(var c,d=1;b=arguments[d++];)for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a};
f.clone=function(a,b,c){if(a&&a.constructor===f){b={};for(c in a)a.hasOwnProperty(c)&&(b[c]=f.clone(a[c]));a=b}return a};f.deepMerge=f.deepCopy=function(a,b,c,d,e,g){c=c||"";d=d||[];for(e in b)if(b.hasOwnProperty(e)&&a[e]!==b[e])if(g=b[e],d.push(c+e),null===g)delete a[e];else if(g&&g.constructor===f){var h=a[e];h&&h.constructor===f||(a[e]={});f.deepMerge(a[e],g,c+e+".",d)}else a[e]=g;return d};f.zip=function(a,b){return a.fold(function(a,d,e){a[d]=b[e];return a},{})};h.remove=function(){for(var a=
this.length,b=l(arguments),c=-1;a--;)~b.indexOf(this[a])&&this.splice(c=a,1);return c};h.each=h.forEach;h.fold=h.reduce;h.foldr=h.reduceRight;h.uniq=h.filter.partial(function(a,b,c){return b==c.lastIndexOf(a)});h.pushUniq=function(a){return-1==this.indexOf(a)?this.push(a):!1};!function(a){k[a]=n[a]=function(){var b=arguments,c=b[0];b[0]=this.fn();return h[a].apply(c,b)}}.byWords()("every filter each map fold foldr some");k.fn=function(){return this};n.fn=function(){return m(this)};q.Fn=m.cache()}(this);
!function(r){function n(a){var b="_",c=a;for(a=a.split("->");1<a.length;)c=a.pop(),b=a.pop().match(/\w+/g)||"",a.length&&a.push("(function("+b+"){return("+c+")})");return new Function(b,"return("+c+")")}var h=Array.prototype,k=Function.prototype,p=String.prototype,f=Object,m=f.prototype.hasOwnProperty,l=k.call.bind(h.slice),q=[];k.construct=function(a){var b=a.length;return b?(q[b]||(q[b]=n("t a->new t(a["+f.keys(l(a)).join("],a[")+"])")))(this,a):new this};k.partial=function(){var a=this,b=l(arguments);
return function(){return a.apply(this,b.concat.apply(b,arguments))}};k.byWords=function(a,b){var c=this;return function(){var d=this,e=d,g=arguments;(g[a|=0]||"").replace(b||/\S+/g,function(b){g[a]=b;e=c.apply(d,g)});return e}};k.byKeyVal=function(){var a=this;return function(b){var c,d=l(arguments);if("object"==typeof b)for(c in b)d[0]=c,d[1]=b[c],c=a.apply(this,d);else c=a.apply(this,d);return c}};k.cache=function(a,b,c){var d=this,e=c||{},g=function(){var c=arguments,f=!!a||this instanceof g,h=
b?b.apply(d,c):f+":"+c.length+":"+l(c);return h in e?e[h]:e[h]=f?d.construct(c):d.apply(this,c)};g.origin=d;g.cached=e;g.extend=function(){return d.extend.apply(d,arguments).cache(a,b,c)};g.prototype=d.prototype;return g};k.extend=function(){function a(){return c.apply(this,arguments)}var b,c=this,d=0;for(a.prototype=f.create(c.prototype);b=arguments[d++];)f.merge(a.prototype,b);return a.prototype.constructor=a};k.ttl=function(a,b){var c=this,d=setTimeout(function(){a=0;b&&b()},a);return function(){clearTimeout(d);
a&&c.apply(null,arguments)}};k.once=function(a){var b,c,d=this;return function(){clearTimeout(b);c=arguments;b=setTimeout(function(){d.apply(null,c)},a)}};k.rate=function(a,b){var c,d,e=this,g=0;return function(){var f=+new Date;clearTimeout(c);f>g?(g=f+a,e.apply(null,arguments)):b&&(d=arguments,c=setTimeout(function(){e.apply(null,d)},g-f))}};f.each=function(a,b,c,d){if(a)for(d in a)m.call(a,d)&&b.call(c,a[d],d,a)};f.merge=function(a,b){for(var c,d=1;b=arguments[d++];)for(c in b)m.call(b,c)&&(a[c]=
b[c]);return a};f.clone=function(a,b,c){if(a&&a.constructor===f){b={};for(c in a)m.call(a,c)&&(b[c]=f.clone(a[c]));a=b}return a};f.deepMerge=f.deepCopy=function(a,b,c,d,e,g){c=c||"";d=d||[];for(e in b)if(m.call(b,e)&&a[e]!==b[e])if(g=b[e],d.push(c+e),null===g)delete a[e];else if(g&&g.constructor===f){var h=a[e];h&&h.constructor===f||(a[e]={});f.deepMerge(a[e],g,c+e+".",d)}else a[e]=g;return d};f.zip=function(a,b){return a.fold(function(a,d,e){a[d]=b[e];return a},{})};h.remove=function(){for(var a=
this.length,b=l(arguments),c=-1;a--;)~b.indexOf(this[a])&&this.splice(c=a,1);return c};h.each=h.forEach;h.fold=h.reduce;h.foldr=h.reduceRight;h.uniq=h.filter.partial(function(a,b,c){return b==c.lastIndexOf(a)});h.pushUniq=function(a){return-1==this.indexOf(a)?this.push(a):!1};!function(a){k[a]=p[a]=function(){var b=arguments,c=b[0];b[0]=this.fn();return h[a].apply(c,b)}}.byWords()("every filter each map fold foldr some");k.fn=function(){return this};p.fn=function(){return n(this)};r.Fn=n.cache()}(this);
{
"name": "functional-lite",
"version": "0.2.4",
"version": "0.2.6",
"stability": 2,

@@ -26,5 +26,5 @@ "license": "MIT",

"devDependencies": {
"browser-upgrade-lite": ">=1.0.1",
"buildman": "*",
"testman": ">=0.1.3",
"browser-upgrade-lite": ">=0.1.8"
"testman": ">=0.1.3"
},

@@ -31,0 +31,0 @@ "buildman": {

@@ -16,4 +16,4 @@ [GitHub repo]: https://github.com/litejs/functional-lite

@version 0.2.4
@date 2014-06-10
@version 0.2.6
@date 2014-06-17
@stability 2 - Unstable

@@ -20,0 +20,0 @@

@@ -75,4 +75,4 @@

it ("should have Object.clone").
ok(function(){
var obj = { a:1, b:2 }
ok(function() {
var obj = { hasOwnProperty:"prop", b:2 }
, clone = Object.clone(obj)

@@ -83,4 +83,4 @@

it ("should have Object.each").
ok(function(){
var obj = { a:1, b:2 }
ok(function() {
var obj = { hasOwnProperty:"prop", b:2 }
, out = ""

@@ -91,3 +91,3 @@

})
return out == "a1b2"
return out == "hasOwnPropertypropb2"
}).

@@ -225,4 +225,4 @@ it ("should have Object.deepMerge").

var t = this
, add1 = function(){ t.count1++ }.rate(100)
, add2 = function(){ t.count2++ }.rate(100, 1)
, add1 = function(){ t.count1++ }.rate(250)
, add2 = function(){ t.count2++ }.rate(250, 1)

@@ -235,3 +235,3 @@ t.count1 = 0

add2()
setTimeout( i ? function(){call(cb, i-1)} : cb, 40)
setTimeout( i ? function(){call(cb, i-1)} : cb, 100)
}

@@ -238,0 +238,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc