New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redash

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redash - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

src/assoc.js

164

dist/redash.js

@@ -23,2 +23,18 @@ (function (global, factory) {

/**
* add : Number -> Number -> Number
*
* @description
* Returns the sum of two numbers.
*
* @when
* You should use this function when you wish to add two numbers together.
*
* @example
* _.add(5)(2) // 7
*
* @example
* const add3 = _.add(3)
* add3(5) // 8
*/
var add = _curry2(function add (a, b) {

@@ -28,2 +44,19 @@ return a + b

var assoc = _curry2(function assoc (a, b) {
var y = {}
, prop
for (prop in a) {
if (a.hasOwnProperty(prop)) {
y[prop] = a[prop]
}
}
for (prop in b) {
if (b.hasOwnProperty(prop)) {
y[prop] = b[prop]
}
}
return y
})
var _slice = [].slice

@@ -69,8 +102,9 @@

var compose = function compose () {
var fns = arguments
, maxIdx = fns.length - 1
var fns = arguments
, _i = fns.length - 1
, fn = fns[_i--]
return _curryN(fns[maxIdx].length, [], function __composition__ () {
var i = maxIdx
, y = fns[i--].apply(null, arguments)
return _curryN(fn.length, [], function __composition__ () {
var i = _i
, y = fn.apply(null, arguments)

@@ -145,9 +179,18 @@ for (; i >= 0; i--) {

, len = xs.length
, ys = []
for (; i < len; i++) {
ys = ys.concat(fn(xs[i], i))
, bs = []
, _i
, b
for (; i < len; i++) {
b = fn(xs[i])
if (Array.isArray(b)) {
for (_i = 0; _i < b.length; _i++) {
bs.push(b[_i])
}
} else {
bs.push(b)
}
}
return ys
return bs
})

@@ -160,8 +203,29 @@

, x
, _i
for (; i < len; i++) {
x = Array.isArray(xs[i]) ? flatten(xs[i]) : xs[i]
x = xs[i]
if (Array.isArray(x)) {
for (_i = 0; _i < x.length; _i++) {
ys.push(x[_i])
}
} else {
ys.push(x)
}
}
return ys
}
var flattenDeep = function flattenDeep (xs) {
var i = 0
, len = xs.length
, ys = []
, x
for (; i < len; i++) {
x = Array.isArray(xs[i]) ? flattenDeep(xs[i]) : xs[i]
ys = ys.concat(x)
}
return ys

@@ -175,3 +239,3 @@ }

for (; i < len; i++) {
fn(xs[i], i);
fn(xs[i])
}

@@ -202,2 +266,25 @@ })

/**
* add : (a -> b) -> [a] -> [b]
*
* @description
* Applies a transformation to every item in an array, returning a new
* array of the same size where each item has been transformed.
*
* @when
* You should use this function when you wish to apply a common transformation
* to every item in an array. For example, if you have an array of objects
* and want a new array containing only a certain property from each object.
*
* @example
* _.map((a) => a + 5, [1,2,3,4,5]) // [6,7,8,9,10]
*
* @example
* _.map((a) => a.id, [{ id: 1 }, { id: 2 }, { id: 3 }]) // [1,2,3]
*
* @example
* const add5 = _.add(5)
* const mapAdd5 = _.map(add5)
* mapAdd5([1,2,3,4]) // [6,7,8,9]
*/
var map = _curry2(function map (fn, xs) {

@@ -209,3 +296,3 @@ var i = 0

for (; i < len; i++) {
ys[i] = fn(xs[i], i)
ys[i] = fn(xs[i])
}

@@ -215,31 +302,2 @@ return ys

var mapValues = _curry2(function mapValues (fn, a) {
var y = {}
, prop
for (prop in a) {
if (a.hasOwnProperty(prop)) {
y[prop] = fn(a[prop])
}
}
return y
})
var merge = _curry2(function merge (a, b) {
var y = {}
, prop
for (prop in a) {
if (a.hasOwnProperty(prop)) {
y[prop] = a[prop]
}
}
for (prop in b) {
if (b.hasOwnProperty(prop)) {
y[prop] = b[prop]
}
}
return y
})
var pipe = function pipe () {

@@ -328,2 +386,12 @@ var fns = arguments

var times = _curry2(function times (fn, n) {
var i = 0
, bs = []
for (; i < n; i++) {
bs.push(fn(i))
}
return bs
})
var toLower = function toLower (a) {

@@ -379,2 +447,4 @@ return a.toLowerCase()

exports.add = add;
exports.assoc = assoc;
exports.merge = assoc;
exports.compose = compose;

@@ -387,2 +457,3 @@ exports.curry = curry;

exports.flatten = flatten;
exports.flattenDeep = flattenDeep;
exports.forEach = forEach;

@@ -394,4 +465,2 @@ exports.head = head;

exports.map = map;
exports.mapValues = mapValues;
exports.merge = merge;
exports.pipe = pipe;

@@ -409,2 +478,3 @@ exports.prop = prop;

exports.takeUntil = takeUntil;
exports.times = times;
exports.toLower = toLower;

@@ -411,0 +481,0 @@ exports.toUpper = toUpper;

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

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.Redash={})}(this,function(n){"use strict";function r(n,t,e){return c(n,function(){var u=t.concat(a.call(arguments));return u.length>=n?e.apply(null,u):r(n,u,e)})}var t=function(n){return function r(t){return arguments.length?n(t):r}},e=function(n){return function r(e,u){switch(arguments.length){case 0:return r;case 1:return t(function(r){return n(e,r)});default:return n(e,u)}}},u=e(function(n,r){return n+r}),a=[].slice,c=function(n,r){switch(n){case 0:return function(){return r.apply(this,arguments)};case 1:return function(n){return r.apply(this,arguments)};case 2:return function(n,t){return r.apply(this,arguments)};case 3:return function(n,t,e){return r.apply(this,arguments)};case 4:return function(n,t,e,u){return r.apply(this,arguments)};case 5:return function(n,t,e,u,a){return r.apply(this,arguments)};case 6:return function(n,t,e,u,a,c){return r.apply(this,arguments)};case 7:return function(n,t,e,u,a,c,o){return r.apply(this,arguments)};case 8:return function(n,t,e,u,a,c,o,i){return r.apply(this,arguments)};case 9:return function(n,t,e,u,a,c,o,i,f){return r.apply(this,arguments)};case 10:return function(n,t,e,u,a,c,o,i,f,s){return r.apply(this,arguments)};default:throw new Error("Arity must be less than or equal to 10.")}},o=function(){var n=arguments,t=n.length-1;return r(n[t].length,[],function(){for(var r=t,e=n[r--].apply(null,arguments);r>=0;r--)e=n[r](e);return e})},i=function(n){return function r(u,a,c){switch(arguments.length){case 0:return r;case 1:return e(function(r,t){return n(u,r,t)});case 2:return t(function(r){return n(u,a,r)});default:return n(u,a,c)}}},f=function(n){switch(n.length){case 0:return n;case 1:return t(n);case 2:return e(n);case 3:return i(n);default:return r(n.length,[],n)}},s=e(function(n,u){switch(n){case 0:return u;case 1:return t(u);case 2:return e(u);case 3:return i(u);default:return r(u.length,[],u)}}),l=e(function(n,r){for(var t,e=0,u=r.length,a=[];u>e;e++)t=r[e],n(t,e)&&a.push(t);return a}),h=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(n(r[t]))return t;return-1}),p=e(function(n,r){for(var t=0,e=r.length,u=[];e>t;t++)u=u.concat(n(r[t],t));return u}),g=function F(n){for(var r,t=0,e=n.length,u=[];e>t;t++)r=Array.isArray(n[t])?F(n[t]):n[t],u=u.concat(r);return u},y=e(function(n,r){for(var t=0,e=r.length;e>t;t++)n(r[t],t)}),m=function(n){return n[0]},v=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(r[t]===n)return t;return-1}),d=Object.keys,w=function(n){return n[n.length-1]},O=e(function(n,r){for(var t=0,e=r.length,u=new Array(e);e>t;t++)u[t]=n(r[t],t);return u}),b=e(function(n,r){var t,e={};for(t in r)r.hasOwnProperty(t)&&(e[t]=n(r[t]));return e}),j=e(function(n,r){var t,e={};for(t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);for(t in r)r.hasOwnProperty(t)&&(e[t]=r[t]);return e}),x=function(){var n=arguments,t=n.length;return r(n[0].length,[],function(){for(var r=0,e=n[r++].apply(null,arguments);t>r;r++)e=n[r](e);return e})},A=e(function(n,r){return r[n]}),k=i(function(n,r,t){return t[n]===r}),P=i(function(n,r,t){for(var e=0,u=t.length;u>e;e++)r=n(r,t[e],e);return r}),z=i(function(n,r,t){for(var e=t.length-1;e>=0;e--)r=n(r,t[e],e);return r}),E=e(function(n,r){for(var t,e=0,u=r.length,a=[];u>e;e++)t=r[e],n(t,e)||a.push(t);return a}),M=[].reverse,U=function(n){return M.call(n.slice(0))},q=function(n){return n.slice(1)},C=e(function(n,r){return r.slice(0,n)}),L=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(n(r[t],t))return r.slice(0,t);return r.slice(0)}),R=function(n){return n.toLowerCase()},I=function(n){return n.toUpperCase()},N=function(n){return function(r){return console.log(n,r),r}},V=function(n){var r,t=[];for(r in n)n.hasOwnProperty(r)&&t.push([r,n[r]]);return t},B=e(function(n,r){for(var t=0,e=Math.min(n.length,r.length),u=new Array(e);e>t;t++)u[t]=[n[t],r[t]];return u}),D=e(function(n,r){for(var t=0,e=Math.min(n.length,r.length),u={};e>t;t++)u[n[t]]=r[t];return u});n.add=u,n.compose=o,n.curry=f,n.curryN=s,n.filter=l,n.findIndex=h,n.flatMap=p,n.flatten=g,n.forEach=y,n.head=m,n.indexOf=v,n.keys=d,n.last=w,n.map=O,n.mapValues=b,n.merge=j,n.pipe=x,n.prop=A,n.propEq=k,n.reduce=P,n.foldl=P,n.reduceRight=z,n.foldr=z,n.reject=E,n.reverse=U,n.tail=q,n.take=C,n.takeUntil=L,n.toLower=R,n.toUpper=I,n.trace=N,n.unzipObj=V,n.zip=B,n.zipObj=D});
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.Redash={})}(this,function(n){"use strict";function r(n,t,e){return c(n,function(){var u=t.concat(o.call(arguments));return u.length>=n?e.apply(null,u):r(n,u,e)})}var t=function(n){return function r(t){return arguments.length?n(t):r}},e=function(n){return function r(e,u){switch(arguments.length){case 0:return r;case 1:return t(function(r){return n(e,r)});default:return n(e,u)}}},u=e(function(n,r){return n+r}),a=e(function(n,r){var t,e={};for(t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);for(t in r)r.hasOwnProperty(t)&&(e[t]=r[t]);return e}),o=[].slice,c=function(n,r){switch(n){case 0:return function(){return r.apply(this,arguments)};case 1:return function(n){return r.apply(this,arguments)};case 2:return function(n,t){return r.apply(this,arguments)};case 3:return function(n,t,e){return r.apply(this,arguments)};case 4:return function(n,t,e,u){return r.apply(this,arguments)};case 5:return function(n,t,e,u,a){return r.apply(this,arguments)};case 6:return function(n,t,e,u,a,o){return r.apply(this,arguments)};case 7:return function(n,t,e,u,a,o,c){return r.apply(this,arguments)};case 8:return function(n,t,e,u,a,o,c,i){return r.apply(this,arguments)};case 9:return function(n,t,e,u,a,o,c,i,f){return r.apply(this,arguments)};case 10:return function(n,t,e,u,a,o,c,i,f,s){return r.apply(this,arguments)};default:throw new Error("Arity must be less than or equal to 10.")}},i=function(){var n=arguments,t=n.length-1,e=n[t--];return r(e.length,[],function(){for(var r=t,u=e.apply(null,arguments);r>=0;r--)u=n[r](u);return u})},f=function(n){return function r(u,a,o){switch(arguments.length){case 0:return r;case 1:return e(function(r,t){return n(u,r,t)});case 2:return t(function(r){return n(u,a,r)});default:return n(u,a,o)}}},s=function(n){switch(n.length){case 0:return n;case 1:return t(n);case 2:return e(n);case 3:return f(n);default:return r(n.length,[],n)}},l=e(function(n,u){switch(n){case 0:return u;case 1:return t(u);case 2:return e(u);case 3:return f(u);default:return r(u.length,[],u)}}),h=e(function(n,r){for(var t,e=0,u=r.length,a=[];u>e;e++)t=r[e],n(t,e)&&a.push(t);return a}),p=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(n(r[t]))return t;return-1}),g=e(function(n,r){for(var t,e,u=0,a=r.length,o=[];a>u;u++)if(e=n(r[u]),Array.isArray(e))for(t=0;t<e.length;t++)o.push(e[t]);else o.push(e);return o}),y=function(n){for(var r,t,e=0,u=n.length,a=[];u>e;e++)if(r=n[e],Array.isArray(r))for(t=0;t<r.length;t++)a.push(r[t]);else a.push(r);return a},m=function H(n){for(var r,t=0,e=n.length,u=[];e>t;t++)r=Array.isArray(n[t])?H(n[t]):n[t],u=u.concat(r);return u},v=e(function(n,r){for(var t=0,e=r.length;e>t;t++)n(r[t])}),d=function(n){return n[0]},w=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(r[t]===n)return t;return-1}),A=Object.keys,O=function(n){return n[n.length-1]},b=e(function(n,r){for(var t=0,e=r.length,u=new Array(e);e>t;t++)u[t]=n(r[t]);return u}),j=function(){var n=arguments,t=n.length;return r(n[0].length,[],function(){for(var r=0,e=n[r++].apply(null,arguments);t>r;r++)e=n[r](e);return e})},x=e(function(n,r){return r[n]}),k=f(function(n,r,t){return t[n]===r}),z=f(function(n,r,t){for(var e=0,u=t.length;u>e;e++)r=n(r,t[e],e);return r}),E=f(function(n,r,t){for(var e=t.length-1;e>=0;e--)r=n(r,t[e],e);return r}),M=e(function(n,r){for(var t,e=0,u=r.length,a=[];u>e;e++)t=r[e],n(t,e)||a.push(t);return a}),P=[].reverse,U=function(n){return P.call(n.slice(0))},q=function(n){return n.slice(1)},C=e(function(n,r){return r.slice(0,n)}),L=e(function(n,r){for(var t=0,e=r.length;e>t;t++)if(n(r[t],t))return r.slice(0,t);return r.slice(0)}),R=e(function(n,r){for(var t=0,e=[];r>t;t++)e.push(n(t));return e}),D=function(n){return n.toLowerCase()},I=function(n){return n.toUpperCase()},N=function(n){return function(r){return console.log(n,r),r}},B=function(n){var r,t=[];for(r in n)n.hasOwnProperty(r)&&t.push([r,n[r]]);return t},F=e(function(n,r){for(var t=0,e=Math.min(n.length,r.length),u=new Array(e);e>t;t++)u[t]=[n[t],r[t]];return u}),G=e(function(n,r){for(var t=0,e=Math.min(n.length,r.length),u={};e>t;t++)u[n[t]]=r[t];return u});n.add=u,n.assoc=a,n.merge=a,n.compose=i,n.curry=s,n.curryN=l,n.filter=h,n.findIndex=p,n.flatMap=g,n.flatten=y,n.flattenDeep=m,n.forEach=v,n.head=d,n.indexOf=w,n.keys=A,n.last=O,n.map=b,n.pipe=j,n.prop=x,n.propEq=k,n.reduce=z,n.foldl=z,n.reduceRight=E,n.foldr=E,n.reject=M,n.reverse=U,n.tail=q,n.take=C,n.takeUntil=L,n.times=R,n.toLower=D,n.toUpper=I,n.trace=N,n.unzipObj=B,n.zip=F,n.zipObj=G});
{
"name": "redash",
"version": "0.4.0",
"version": "0.5.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/redash.js",

@@ -5,3 +5,3 @@ Redash

Redash is a lightweight, functional-first library meant to fill the gap between Ramda and Lodash. All functions are auto-curried and expect data as the last argument to encourage composition. This library's ultimate goal is to remain as lightweight as possible; that means zero dependencies and an incredibly focused API that will give you the right tools for the job and nothing more.
Redash is a lightweight library meant to fill the gap between Ramda (functional) and Lodash (performance). All functions are auto-curried and expect data as the last argument to encourage composition. Redash's ultimate goal is to remain as lightweight as possible; that means zero dependencies and an incredibly focused API that will give you the right tools for the job and nothing more.

@@ -12,7 +12,7 @@ ## Redash vs. Ramda vs. Lodash

------------------ | ------ | ----- | ------ | ---------
Minified (kb) | 3.65 | 39.1 | 60.8 | 66
Minified (kb) | 3.65 | 39.1 | 60.8 | 66
Immutable | Yes | Yes | No | Yes
Functional First | Yes | Yes | No | No
Functional | Yes | Yes | No | Yes
Reference Equality | Yes | No | Yes | Yes
Value Equality | No | Yes | No | No
IE 9+ | Yes | Yes | Yes | Yes
import _curry2 from './internal/_curry2'
/**
* add : Number -> Number -> Number
*
* @description
* Returns the sum of two numbers.
*
* @when
* You should use this function when you wish to add two numbers together.
*
* @example
* _.add(5)(2) // 7
*
* @example
* const add3 = _.add(3)
* add3(5) // 8
*/
var add = _curry2(function add (a, b) {

@@ -4,0 +20,0 @@ return a + b

@@ -1,10 +0,11 @@

import _curryN from './internal/_curryN'
import _curryN from './internal/_curryN'
var compose = function compose () {
var fns = arguments
, maxIdx = fns.length - 1
var fns = arguments
, _i = fns.length - 1
, fn = fns[_i--]
return _curryN(fns[maxIdx].length, [], function __composition__ () {
var i = maxIdx
, y = fns[i--].apply(null, arguments)
return _curryN(fn.length, [], function __composition__ () {
var i = _i
, y = fn.apply(null, arguments)

@@ -11,0 +12,0 @@ for (; i >= 0; i--) {

@@ -6,11 +6,20 @@ import _curry2 from './internal/_curry2'

, len = xs.length
, ys = []
for (; i < len; i++) {
ys = ys.concat(fn(xs[i], i))
, bs = []
, _i
, b
for (; i < len; i++) {
b = fn(xs[i])
if (Array.isArray(b)) {
for (_i = 0; _i < b.length; _i++) {
bs.push(b[_i])
}
} else {
bs.push(b)
}
}
return ys
return bs
})
export default flatMap

@@ -6,8 +6,15 @@ var flatten = function flatten (xs) {

, x
, _i
for (; i < len; i++) {
x = Array.isArray(xs[i]) ? flatten(xs[i]) : xs[i]
ys = ys.concat(x)
x = xs[i]
if (Array.isArray(x)) {
for (_i = 0; _i < x.length; _i++) {
ys.push(x[_i])
}
} else {
ys.push(x)
}
}
return ys

@@ -14,0 +21,0 @@ }

@@ -8,3 +8,3 @@ import _curry2 from './internal/_curry2'

for (; i < len; i++) {
fn(xs[i], i);
fn(xs[i])
}

@@ -11,0 +11,0 @@ })

import _curry2 from './internal/_curry2'
/**
* add : (a -> b) -> [a] -> [b]
*
* @description
* Applies a transformation to every item in an array, returning a new
* array of the same size where each item has been transformed.
*
* @when
* You should use this function when you wish to apply a common transformation
* to every item in an array. For example, if you have an array of objects
* and want a new array containing only a certain property from each object.
*
* @example
* _.map((a) => a + 5, [1,2,3,4,5]) // [6,7,8,9,10]
*
* @example
* _.map((a) => a.id, [{ id: 1 }, { id: 2 }, { id: 3 }]) // [1,2,3]
*
* @example
* const add5 = _.add(5)
* const mapAdd5 = _.map(add5)
* mapAdd5([1,2,3,4]) // [6,7,8,9]
*/
var map = _curry2(function map (fn, xs) {

@@ -9,3 +32,3 @@ var i = 0

for (; i < len; i++) {
ys[i] = fn(xs[i], i)
ys[i] = fn(xs[i])
}

@@ -12,0 +35,0 @@ return ys

export { default as add } from './add'
export { default as assoc } from './assoc'
export { default as merge } from './assoc'
export { default as compose } from './compose'

@@ -9,2 +11,3 @@ export { default as curry } from './curry'

export { default as flatten } from './flatten'
export { default as flattenDeep } from './flattenDeep'
export { default as forEach } from './forEach'

@@ -16,4 +19,2 @@ export { default as head } from './head'

export { default as map } from './map'
export { default as mapValues } from './mapValues'
export { default as merge } from './merge'
export { default as pipe } from './pipe'

@@ -31,2 +32,3 @@ export { default as prop } from './prop'

export { default as takeUntil } from './takeUntil'
export { default as times } from './times'
export { default as toLower } from './toLower'

@@ -33,0 +35,0 @@ export { default as toUpper } from './toUpper'

@@ -5,8 +5,9 @@ var flatten = Redash.flatten

it('Should be a function.', function () {
expect(flatten).to.be.a('function')
expect(flatten).to.be.a('function')
})
it('Should deeply flatten an array.', function () {
expect(flatten([1,2,[3],[4,5,[6,[7,8,9]]]])).to.deep.equal([1,2,3,4,5,6,7,8,9])
it('Should shallowly flatten an array.', function () {
expect(flatten([1,2,[3],[4,5,[6,[7,8,9]]]]))
.to.deep.equal([1,2,3,4,5, [6, [7,8,9]]])
})
})

@@ -5,3 +5,3 @@ var forEach = Redash.forEach

var _spies
beforeEach(function () {

@@ -11,17 +11,17 @@ _spies = {}

})
it('Should be a function', function () {
expect(forEach).to.be.a('function')
})
it('Should be curried', function () {
var _forEach = forEach(_spies.noop)
_spies.noop.should.not.have.been.called
expect(_forEach).to.be.a('function')
expect(_forEach([1])).to.be.undefined
_spies.noop.should.have.been.calledOnce
})
it('Should not call the provided function if the provided list is empty', function () {

@@ -31,8 +31,8 @@ forEach(_spies.noop, [])

})
it('Should call the provided function with each item in the list', function () {
_spies.noop.should.not.have.been.called
forEach(_spies.noop, [1,2,3])
_spies.noop.should.have.been.calledThrice

@@ -43,9 +43,2 @@ _spies.noop.getCall(0).should.have.been.calledWith(1)

})
it('Should provide the index as the second argument to the callback function', function () {
forEach(_spies.noop, [1,2,3])
_spies.noop.getCall(0).should.have.been.calledWith(1, 0)
_spies.noop.getCall(1).should.have.been.calledWith(2, 1)
_spies.noop.getCall(2).should.have.been.calledWith(3, 2)
})
})
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