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

@vates/compose

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vates/compose - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

4

index.js

@@ -35,3 +35,3 @@ 'use strict'

for (let i = 1; i < n; ++i) {
value = await fns[i](value)
value = await fns[i].call(this, value)
}

@@ -43,3 +43,3 @@ return value

for (let i = 1; i < n; ++i) {
value = fns[i](value)
value = fns[i].call(this, value)
}

@@ -46,0 +46,0 @@ return value

@@ -40,16 +40,28 @@ /* eslint-env jest */

it('first function receives this and all args', () => {
expect.assertions(2)
it('forwards all args to first function', () => {
expect.assertions(1)
const expectedArgs = [Math.random(), Math.random()]
const expectedThis = {}
compose(
function (...args) {
expect(this).toBe(expectedThis)
(...args) => {
expect(args).toEqual(expectedArgs)
},
// add a second function to use the one function special case
// add a second function to avoid the one function special case
Function.prototype
).apply(expectedThis, expectedArgs)
)(...expectedArgs)
})
it('forwards context to all functions', () => {
expect.assertions(2)
const expectedThis = {}
compose(
function () {
expect(this).toBe(expectedThis)
},
function () {
expect(this).toBe(expectedThis)
}
).call(expectedThis)
})
})

@@ -17,3 +17,3 @@ {

"license": "ISC",
"version": "1.2.0",
"version": "2.0.0",
"engines": {

@@ -20,0 +20,0 @@ "node": ">=7.6"

@@ -14,4 +14,6 @@ ```js

The first function is called with the context and all arguments of the composed function:
> The call context (`this`) of the composed function is forwarded to all functions.
The first function is called with all arguments of the composed function:
```js

@@ -18,0 +20,0 @@ const add = (x, y) => x + y

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