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

dethunking-compose

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dethunking-compose - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

es6/index.js

39

index.js

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

[object Object]
'use strict';
var pipe = function () {
var fns = [].slice.call(arguments)
var piped = nice_to_string('pipe', fns, function (val) {
return fns.reduce(function (v, f) {
return safe_call(piped, f, v)
}, val)
})
return piped
}
var compose = function () {
var fns = [].slice.call(arguments)
return nice_to_string('compose', fns, pipe.apply(undefined, fns.reverse()))
}
var safe_call = function (piped, fn, val) {
try {
return fn()(val)
} catch (e) {
e.message = piped.toString() + ' blew up on ' + fn().toString()
throw e
}
}
var nice_to_string = function (name, fns, piped) {
piped.toString = function () {
return name + '(' + fns.map(function (fn) {
return fn().toString()
}).join(', ') + ')'
}
return piped
}
module.exports = compose
module.exports.pipe = pipe

17

package.json
{
"name": "dethunking-compose",
"version": "0.0.1",
"version": "0.1.0",
"description": "Lazy evaluation + compose",
"main": "index.js",
"scripts": {
"prepublish": "./build",
"test": "babel-tape-runner test/*.test.js"
"test": "tape test/*.test.js"
},

@@ -22,9 +21,2 @@ "repository": {

"author": "rjmk",
"babel": {
"plugins": [
"transform-es2015-arrow-functions",
"babel-plugin-transform-es2015-parameters",
"babel-plugin-transform-es2015-spread"
]
},
"license": "ISC",

@@ -36,7 +28,2 @@ "bugs": {

"devDependencies": {
"babel-core": "^6.2.1",
"babel-plugin-transform-es2015-arrow-functions": "^6.1.18",
"babel-plugin-transform-es2015-parameters": "^6.1.18",
"babel-plugin-transform-es2015-spread": "^6.1.18",
"babel-tape-runner": "^1.3.0",
"tape": "^4.2.2"

@@ -43,0 +30,0 @@ },

@@ -10,8 +10,9 @@ 'use strict'

t.plan(1)
var composed_pass = compose(
() => id
)
var composed_pass = compose(function () {
return id
})
var id = x =>
x
var id = function (x) {
return x
}

@@ -27,14 +28,19 @@ var actual = composed_pass('ok')

t.plan(1)
var composed_pass = compose(
() => id
, () => id
, () => to_upper
, () => id
)
var composed_pass = compose(function () {
return id
}, function () {
return id
}, function () {
return to_upper
}, function () {
return id
})
var id = x =>
x
var id = function (x) {
return x
}
var to_upper = str =>
str.toUpperCase()
var to_upper = function (str) {
return str.toUpperCase()
}

@@ -50,10 +56,13 @@ var actual = composed_pass('ok')

t.plan(1)
var composed_pass = compose(
() => id
, () => id
, () => id
)
var composed_pass = compose(function () {
return id
}, function () {
return id
}, function () {
return id
})
var id = x =>
x === 'ok'
var id = function (x) {
return x
}

@@ -63,5 +72,5 @@ var test_string = id.toString()

t.equal(
composed_pass.toString()
, 'compose(' + [test_string, test_string, test_string].join(', ') + ')'
, 'composed function stringifies nicely'
composed_pass.toString(),
'compose(' + [test_string, test_string, test_string].join(', ') + ')',
'composed function stringifies nicely'
)

@@ -73,13 +82,17 @@ })

t.plan(1)
var piped_pass = pipe(
() => id
, () => to_upper
, () => id
)
var piped_pass = pipe(function () {
return id
}, function () {
return to_upper
}, function () {
return id
})
var id = x =>
x
var id = function (x) {
return x
}
var to_upper = str =>
str.toUpperCase()
var to_upper = function (str) {
return str.toUpperCase()
}

@@ -95,10 +108,13 @@ var actual = piped_pass('ok')

t.plan(1)
var piped_pass = pipe(
() => id
, () => id
, () => id
)
var piped_pass = pipe(function () {
return id
}, function () {
return id
}, function () {
return id
})
var id = x =>
x
var id = function (x) {
return x
}

@@ -108,5 +124,5 @@ var test_string = id.toString()

t.equal(
piped_pass.toString()
, 'pipe(' + [test_string, test_string, test_string].join(', ') + ')'
, 'piped function stringifies nicely'
piped_pass.toString(),
'pipe(' + [test_string, test_string, test_string].join(', ') + ')',
'piped function stringifies nicely'
)

@@ -118,10 +134,13 @@ })

t.plan(1)
var piped_pass = pipe(
() => id
, () => id(3)
, () => id
)
var piped_pass = pipe(function () {
return id
}, function () {
return id(3)
}, function () {
return id
})
var id = x =>
x
var id = function (x) {
return x
}

@@ -131,8 +150,5 @@ try {

} catch (e) {
t.equal(
e.message,
piped_pass.toString() + ' blew up on 3',
'correct message'
)
t.equal(e.message, piped_pass.toString() + ' blew up on 3', 'correct error')
}
})

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