collect.js
Advanced tools
Comparing version 4.0.21 to 4.0.22
{ | ||
"name": "collect.js", | ||
"version": "4.0.21", | ||
"version": "4.0.22", | ||
"description": "Convenient and dependency free wrapper for working with arrays and objects.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1335,2 +1335,43 @@ # <img src="https://raw.githubusercontent.com/ecrmnn/collect.js/master/collectjs.jpg" alt="collect.js"> | ||
You can use "dot notation" to access nested values | ||
```js | ||
const collection = collect([{ | ||
name: 'John', | ||
roles: [{ | ||
name: 'Editor', | ||
}, { | ||
name: 'Admin', | ||
}], | ||
}]); | ||
const plucked = collection.pluck('roles.0.name'); | ||
plucked.all(); | ||
//=> ['Editor'] | ||
``` | ||
"Dot notation" supports "wildcard" | ||
```js | ||
const collection = collect([{ | ||
name: 'John', | ||
roles: [{ | ||
name: 'Editor', | ||
}, { | ||
name: 'Admin', | ||
}], | ||
}]); | ||
const plucked = collection.pluck('roles.*.name'); | ||
plucked.all(); | ||
//=> [ | ||
//=> [ | ||
//=> 'Editor', | ||
//=> 'Admin', | ||
//=> ], | ||
//=> ] | ||
``` | ||
#### ``pop()`` | ||
@@ -1337,0 +1378,0 @@ The pop method removes and returns the last item from the collection: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
380226
2139