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

funkis

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funkis - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

lib/and.js

5

index.js
module.exports =
{ apply : require('./lib/apply')
{ and : require('./lib/and')
, apply : require('./lib/apply')
, assert : require('./lib/assert')

@@ -8,2 +9,3 @@ , call : require('./lib/call')

, count : require('./lib/count')
, dec : require('./lib/dec')
, each : require('./lib/each')

@@ -14,2 +16,3 @@ , eq : require('./lib/eq')

, identity : require('./lib/identity')
, inc : require('./lib/inc')
, is : require('./lib/is')

@@ -16,0 +19,0 @@ , isEmpty : require('./lib/isEmpty')

18

lib/get.js

@@ -5,8 +5,18 @@ module.exports = get

if (isnt(map)) return notFound
if (!map.hasOwnProperty(key)) return notFound
return map[key]
if (is(Array, key)) {
if (key.length) {
var next = get(map, key[0], no)
return next === no? notFound : get(next, key.slice(1), notFound)
} else {
return map
}
} else {
return map.hasOwnProperty(key)? map[key] : notFound
}
}
var isnt = require('./isnt')
, is = require('./is')
var assert = require('./assert')
, isnt = require('./isnt')
, is = require('./is')
, no = {}

@@ -10,29 +10,29 @@ module.exports = variadic

case -1 : return fn
case 0 : return function (rest) { return apply(fn, this, argc, slice(arguments)) }
case 1 : return function (a, rest) { return apply(fn, this, argc, slice(arguments)) }
case 2 : return function (a, b, rest) { return apply(fn, this, argc, slice(arguments)) }
case 3 : return function (a, b, c, rest) { return apply(fn, this, argc, slice(arguments)) }
case 4 : return function (a, b, c, d, rest) { return apply(fn, this, argc, slice(arguments)) }
case 5 : return function (a, b, c, d, e, rest) { return apply(fn, this, argc, slice(arguments)) }
case 6 : return function (a, b, c, d, e, f, rest) { return apply(fn, this, argc, slice(arguments)) }
case 7 : return function (a, b, c, d, e, f, g, rest) { return apply(fn, this, argc, slice(arguments)) }
case 8 : return function (a, b, c, d, e, f, g, h, rest) { return apply(fn, this, argc, slice(arguments)) }
case 9 : return function (a, b, c, d, e, f, g, h, i, rest) { return apply(fn, this, argc, slice(arguments)) }
case 10 : return function (a, b, c, d, e, f, g, h, i, j, rest) { return apply(fn, this, argc, slice(arguments)) }
case 11 : return function (a, b, c, d, e, f, g, h, i, j, k, rest) { return apply(fn, this, argc, slice(arguments)) }
case 12 : return function (a, b, c, d, e, f, g, h, i, j, k, l, rest) { return apply(fn, this, argc, slice(arguments)) }
case 13 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, rest) { return apply(fn, this, argc, slice(arguments)) }
case 14 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, rest) { return apply(fn, this, argc, slice(arguments)) }
case 15 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, rest) { return apply(fn, this, argc, slice(arguments)) }
case 16 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, rest) { return apply(fn, this, argc, slice(arguments)) }
case 17 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, rest) { return apply(fn, this, argc, slice(arguments)) }
case 18 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, rest) { return apply(fn, this, argc, slice(arguments)) }
case 19 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, rest) { return apply(fn, this, argc, slice(arguments)) }
case 20 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, rest) { return apply(fn, this, argc, slice(arguments)) }
case 21 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, rest) { return apply(fn, this, argc, slice(arguments)) }
case 22 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, rest) { return apply(fn, this, argc, slice(arguments)) }
case 23 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, rest) { return apply(fn, this, argc, slice(arguments)) }
case 24 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, rest) { return apply(fn, this, argc, slice(arguments)) }
case 25 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, rest) { return apply(fn, this, argc, slice(arguments)) }
default : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, rest) { return apply(fn, this, argc, slice(arguments)) }
case 0 : return function (rest) { return apply(fn, this, argc, arguments) }
case 1 : return function (a, rest) { return apply(fn, this, argc, arguments) }
case 2 : return function (a, b, rest) { return apply(fn, this, argc, arguments) }
case 3 : return function (a, b, c, rest) { return apply(fn, this, argc, arguments) }
case 4 : return function (a, b, c, d, rest) { return apply(fn, this, argc, arguments) }
case 5 : return function (a, b, c, d, e, rest) { return apply(fn, this, argc, arguments) }
case 6 : return function (a, b, c, d, e, f, rest) { return apply(fn, this, argc, arguments) }
case 7 : return function (a, b, c, d, e, f, g, rest) { return apply(fn, this, argc, arguments) }
case 8 : return function (a, b, c, d, e, f, g, h, rest) { return apply(fn, this, argc, arguments) }
case 9 : return function (a, b, c, d, e, f, g, h, i, rest) { return apply(fn, this, argc, arguments) }
case 10 : return function (a, b, c, d, e, f, g, h, i, j, rest) { return apply(fn, this, argc, arguments) }
case 11 : return function (a, b, c, d, e, f, g, h, i, j, k, rest) { return apply(fn, this, argc, arguments) }
case 12 : return function (a, b, c, d, e, f, g, h, i, j, k, l, rest) { return apply(fn, this, argc, arguments) }
case 13 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, rest) { return apply(fn, this, argc, arguments) }
case 14 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, rest) { return apply(fn, this, argc, arguments) }
case 15 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, rest) { return apply(fn, this, argc, arguments) }
case 16 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, rest) { return apply(fn, this, argc, arguments) }
case 17 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, rest) { return apply(fn, this, argc, arguments) }
case 18 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, rest) { return apply(fn, this, argc, arguments) }
case 19 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, rest) { return apply(fn, this, argc, arguments) }
case 20 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, rest) { return apply(fn, this, argc, arguments) }
case 21 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, rest) { return apply(fn, this, argc, arguments) }
case 22 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, rest) { return apply(fn, this, argc, arguments) }
case 23 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, rest) { return apply(fn, this, argc, arguments) }
case 24 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, rest) { return apply(fn, this, argc, arguments) }
case 25 : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, rest) { return apply(fn, this, argc, arguments) }
default : return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, rest) { return apply(fn, this, argc, arguments) }
}

@@ -42,4 +42,11 @@ }

function apply(fn, host, argc, argv) {
var rest = slice(argv, argc)
argv = slice(argv, 0, argc)
var rest = []
if (argv.length < argc) {
argv = slice(argv).concat(Array(argc - argv.length))
} else {
rest = slice(argv, argc)
argv = slice(argv, 0, argc)
}
argv.push(rest)

@@ -46,0 +53,0 @@

{
"name": "funkis",
"version": "0.1.4",
"version": "0.2.0",
"description": "Functional programming in JavaScript.",

@@ -12,11 +12,8 @@ "main": "index.js",

"devDependencies": {
"coveralls": "~2.8.0",
"expect.js": "^0.3.1",
"istanbul": "~0.2.4",
"mocha": "~1.17.1",
"chai": "~1.9.0",
"coveralls": "~2.8.0",
"mocha-lcov-reporter": "0.0.1",
"sinon": "~1.9.0",
"mocha-sinon": "~1.1.0",
"sinon-chai": "~2.5.0",
"expect.js": "^0.3.1"
"must": "git://github.com/mstade/js-must#throw-error-instance"
},

@@ -23,0 +20,0 @@ "repository": {

@@ -26,3 +26,3 @@ describe('apply', function() {

it('should call the function without arguments', function(done) {
var fn = function() {
var fn = function() {
expect(arguments.length).to.equal(0)

@@ -36,3 +36,3 @@ done()

it('should proxy the functions return value', function() {
expect(apply(constantly(3))).to.equal(3)
expect(apply(constantly(3))).to.equal(3)
})

@@ -42,5 +42,5 @@

it('should not affect the binding', function(done) {
var owner = {}
var owner = {}
var fn = function() {
var fn = function() {
expect(arguments.length).to.equal(0)

@@ -58,3 +58,3 @@ expect(this).to.equal(owner)

it('should call the function with arguments', function(done) {
var fn = function() {
var fn = function() {
expect(slice(arguments)).to.eql([1, true, 'wibble'])

@@ -68,3 +68,3 @@ done()

it('should proxy the functions return value', function() {
expect(apply(constantly, [3])).to.be.a('function')
expect(apply(constantly, [3])).to.be.a(Function)
})

@@ -74,5 +74,5 @@

it('should not affect the binding', function(done) {
var owner = {}
var owner = {}
var fn = function() {
var fn = function() {
expect(slice(arguments)).to.eql([1, true, 'wibble'])

@@ -91,5 +91,5 @@ expect(this).to.equal(owner)

var constantly = require('../lib/constantly')
, expect = require('chai').expect
, expect = require('must')
, slice = require('../lib/slice')
, apply = require('../lib/apply')
, each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, assert = require('../lib/assert')

@@ -27,3 +27,3 @@ , each = require('../lib/each')

describe('and also given an instance of Error', function() {
it('should throw that error', function() {
it('should throw that instance', function() {
var err = new Error('sad face')

@@ -30,0 +30,0 @@ expect($(assert, x, err)).to.throw(err)

@@ -76,5 +76,5 @@ describe('call', function() {

var expect = require('chai').expect
var expect = require('must')
, slice = require('../lib/slice')
, each = require('../lib/each')
, call = require('../lib/call')
var partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, comp = require('../lib/compose')

@@ -4,0 +4,0 @@

var constantly = require('../lib/constantly')
, expect = require('chai').expect
, expect = require('must')
, each = require('../lib/each')

@@ -4,0 +4,0 @@ , src = require('../lib/src')

var partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, count = require('../lib/count')

@@ -4,0 +4,0 @@ , seq = require('../lib/seq')

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

var expect = require('chai').expect
var expect = require('must')
, each = require('../lib/each')

@@ -3,0 +3,0 @@ , src = require('../lib/src')

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

var expect = require('chai').expect
var expect = require('must')
, each = require('../lib/each')

@@ -3,0 +3,0 @@ , eq = require('../lib/eq')

@@ -5,12 +5,14 @@ var fs = require('fs')

, funkis = require('../')
, expect = require('expect.js')
, expect = require('must')
describe('funkis', function() {
it('should export every function in lib/', function() {
var names = fs.readdirSync(path.join(__dirname, '../lib'))
.map(function(file) {
var module = path.basename(file, '.js')
expect(funkis).to.have.key(module)
})
var names = fs.readdirSync(path.join(__dirname, '../lib')).map(function(file) {
return path.basename(file, '.js')
})
each(names, function(name) {
expect(funkis).to.have.property(name)
})
})
})
const partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, each = require('../lib/each')

@@ -15,3 +15,3 @@ , get = require('../lib/get')

describe('and when the value of `key` is logically false', function() {
describe('and when the value of `map[key]` is logically false', function() {
it('should still return the value of `key`', function() {

@@ -75,2 +75,12 @@ each([null, undefined, false], function(x) {

})
describe('when given an array as `key`', function() {
it('should work recursively', function() {
const map = { a: { b: { c: { d: 'wibble' } } } }
, notFound = {}
expect(get(map, ['a', 'b', 'c', 'd'])).to.equal('wibble')
expect(get(map, ['a', 'b', 'c', 'x'], notFound)).to.equal(notFound)
})
})
})

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

var expect = require('chai').expect
var expect = require('must')
, gt = require('../lib/gt')

@@ -3,0 +3,0 @@

var identity = require('../lib/identity')
, expect = require('chai').expect
, expect = require('must')
, each = require('../lib/each')

@@ -4,0 +4,0 @@ , type = require('../lib/type')

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

var expect = require('chai').expect
var expect = require('must')
, range = require('../lib/range')

@@ -3,0 +3,0 @@ , each = require('../lib/each')

var isEmpty = require('../lib/isEmpty')
, expect = require('chai').expect
, expect = require('must')
, each = require('../lib/each')

@@ -4,0 +4,0 @@ , seq = require('../lib/seq')

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

var expect = require('chai').expect
var expect = require('must')
, isnt = require('../lib/isnt')

@@ -3,0 +3,0 @@ , each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, lt = require('../lib/lt')

@@ -3,0 +3,0 @@

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

var expect = require('chai').expect
var expect = require('must')
, merge = require('../lib/merge')

@@ -11,3 +11,3 @@

expect(foo).to.not.equal(bar)
expect(bar).to.have.key('wibble')
expect(bar).to.have.own('wibble')
expect(bar.wibble).to.equal(1)

@@ -25,3 +25,3 @@ })

expect(m).to.not.equal(b)
expect(m).to.have.keys('foo', 'bar')
expect(m).to.have.keys(['foo', 'bar'])
expect(m.foo).to.equal(1)

@@ -36,3 +36,3 @@ expect(m.bar).to.equal(2)

expect(m).to.have.keys('foo', 'bar')
expect(m).to.have.keys(['foo', 'bar'])
expect(m.foo).to.equal(2)

@@ -53,3 +53,3 @@ expect(m.bar).to.equal(3)

expect(m).to.not.equal(c)
expect(m).to.have.keys('foo', 'bar', 'baz')
expect(m).to.have.keys(['foo', 'bar', 'baz'])
expect(m.foo).to.equal(1)

@@ -66,3 +66,3 @@ expect(m.bar).to.equal(2)

expect(m).to.have.keys('foo', 'bar', 'baz')
expect(m).to.have.keys(['foo', 'bar', 'baz'])
expect(m.foo).to.equal(6)

@@ -69,0 +69,0 @@ expect(m.bar).to.equal(3)

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

var expect = require('chai').expect
var expect = require('must')
, each = require('../lib/each')

@@ -3,0 +3,0 @@ , src = require('../lib/src')

var partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, nth = require('../lib/nth')

@@ -4,0 +4,0 @@

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

var expect = require('chai').expect
var expect = require('must')
, once = require('../lib/once')

@@ -9,3 +9,3 @@

it('should return another function named `once`', function() {
expect(ofn).to.be.a('function')
expect(ofn).to.be.a(Function)
expect(ofn.name).to.equal('once')

@@ -12,0 +12,0 @@ })

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

var expect = require("chai").expect
var expect = require("must")
, $ = require("../lib/partial")

@@ -3,0 +3,0 @@

var partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, pipe = require('../lib/pipe')

@@ -4,0 +4,0 @@

@@ -67,3 +67,3 @@ describe('range', function() {

var expect = require('chai').expect
var expect = require('must')
, range = require('../lib/range')

@@ -70,0 +70,0 @@ , each = require('../lib/each')

var repeatedly = require('../lib/repeatedly')
, partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, range = require('../lib/range')

@@ -5,0 +5,0 @@ , each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, count = require('../lib/count')

@@ -89,3 +89,3 @@ , each = require('../lib/each')

var chr = ['I', 'ñ', 't', 'ë', 'r', 'n', 'â', 't', 'i', 'ô', 'n', 'à', 'l', 'i', 'z', 'æ', 't', 'i', 'ø', 'n', '☃', '💩']
, str = seq(chr.join(''))
, str = seq(chr.join(''))

@@ -118,3 +118,3 @@ expect(str.length).to.eql(chr.length)

each(take(5, s), function(n) {
expect(n).to.be.within(0, 1)
expect(n).to.be.between(0, 1)
})

@@ -121,0 +121,0 @@ })

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

var expect = require('chai').expect
var expect = require('must')
, slice = require('../lib/slice')

@@ -3,0 +3,0 @@ , each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, each = require('../lib/each')

@@ -3,0 +3,0 @@ , src = require('../lib/src')

var partial = require('../lib/partial')
, expect = require('chai').expect
, expect = require('must')
, slice = require('../lib/slice')

@@ -4,0 +4,0 @@ , each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, global = (function() { return this }())

@@ -13,3 +13,3 @@ , thunk = require('../lib/thunk')

expect(th).to.be.a('function')
expect(th).to.be.a(Function)
expect(th.length).to.equal(0)

@@ -51,3 +51,3 @@ expect(th.name).to.equal('thunk')

expect(th).to.be.a('function')
expect(th).to.be.a(Function)
expect(th.length).to.equal(0)

@@ -89,3 +89,3 @@ })

var th = thunk(function() {}, 1, 2, 3)
expect(th).to.be.a('function')
expect(th).to.be.a(Function)
expect(th.length).to.equal(0)

@@ -223,3 +223,3 @@ expect(th.name).to.equal('thunk')

expect(th).to.be.a('function')
expect(th).to.be.a(Function)
expect(th.length).to.equal(0)

@@ -226,0 +226,0 @@ expect(th.name).to.equal('thunk')

var trampoline = require('../lib/trampoline')
, expect = require('chai').expect
, expect = require('must')
, thunk = require('../lib/thunk')

@@ -4,0 +4,0 @@ , each = require('../lib/each')

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

var expect = require('chai').expect
var expect = require('must')
, range = require('../lib/range')

@@ -3,0 +3,0 @@ , type = require('../lib/type')

var constantly = require('../lib/constantly')
, expect = require('chai').expect
, expect = require('must')
, type = require('../lib/type')

@@ -4,0 +4,0 @@ , val = require('../lib/val')

var variadic = require('../lib/variadic')
, expect = require('chai').expect
, expect = require('must')
, thunk = require('../lib/thunk')

@@ -8,2 +8,3 @@ , range = require('../lib/range')

, src = require('../lib/src')
, is = require('../lib/is')

@@ -36,2 +37,21 @@ describe('`variadic`', function() {

describe('of arity 1', function() {
it('should return a 1-arity function', function() {
var fn = variadic(function(rest) {})
expect(fn).to.have.length(1)
})
describe('when called without arguments', function() {
it('should set `rest` to an empty array', function(done) {
var fn = variadic(function(rest) {
is(Array, rest) && expect(rest).to.have.length(0)
done()
})
fn()
})
})
})
each(range(1, 28), function(n) {

@@ -54,3 +74,3 @@ describe('of arity '+n, function() {

var fn = Function.apply(Function, sig.concat(
[ 'this.expect(arguments).to.have.length('+(args.length + 1)+')'
[ 'this.expect(arguments).to.have.length('+sig.length+')'
, 'this.expect(rest).to.be.empty'

@@ -57,0 +77,0 @@ ].join('\n')

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

var expect = require('chai').expect
var expect = require('must')
, range = require('../lib/range')

@@ -3,0 +3,0 @@ , each = require('../lib/each')

Sorry, the diff of this file is not supported yet

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