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

@supercharge/collections

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supercharge/collections - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

6

CHANGELOG.md
# Changelog
## [1.9.0](https://github.com/superchargejs/collections/compare/v1.8.0...v1.9.0) - 2019-10-26
### Added
- `.pop()` method
## [1.8.0](https://github.com/superchargejs/collections/compare/v1.7.0...v1.8.0) - 2019-10-24

@@ -5,0 +11,0 @@

2

package.json
{
"name": "@supercharge/collections",
"description": "Supercharge collections",
"version": "1.8.0",
"version": "1.9.0",
"author": "Marcus Pöhls <marcus@futurestud.io>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -320,2 +320,17 @@ 'use strict'

/**
* Removes and returns the last item from the collection
*
* @param {}
*
* @returns {Number}
*/
pop () {
const collection = this.clone()
this.splice(-1, 1)
return collection._enqueue('pop').all()
}
/**
* Asynchronous version of Array#reduce(). It invokes the `reducer`

@@ -322,0 +337,0 @@ * function sequentially on each `array` item. The reducer

@@ -345,2 +345,13 @@ 'use strict'

/**
* Removes and returns the last item from the collection
*
* @param {}
*
* @returns {Number}
*/
pop () {
return this.items.pop()
}
/**
* Asynchronous version of Array#reduce(). It invokes the `reducer`

@@ -347,0 +358,0 @@ * function sequentially on each `array` item. The reducer

@@ -631,12 +631,28 @@ 'use strict'

it('pop', async () => {
expect(
await Collect([1, 2, 3]).pop()
).to.equal(3)
const collection = Collect([])
const undef = await collection.pop()
expect(undef).to.equal(undefined)
expect(await collection.all()).to.equal([])
const pipeline = Collect([1, 2, 3, 4, 5]).map(item => item * 2).filter(item => item > 5)
const ten = await pipeline.pop()
expect(ten).to.equal(10)
expect(await pipeline.all()).to.equal([6, 8])
})
it('shift', async () => {
const collection = Collect([1, 2, 3])
const first = await collection.shift()
expect(first).to.equal(1)
const one = await collection.shift()
expect(one).to.equal(1)
expect(await collection.all()).to.equal([2, 3])
const pipeline = Collect([1, 2, 3]).map(item => item * 2).filter(item => item > 5)
const pipeline = Collect([1, 2, 3, 4, 5]).map(item => item * 2).filter(item => item > 5)
const six = await pipeline.shift()
expect(six).to.equal(6)
expect(await pipeline.all()).to.equal([])
expect(await pipeline.all()).to.equal([8, 10])
})

@@ -643,0 +659,0 @@

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