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

pick-by-alias

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pick-by-alias - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

index.js

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

}
else {
else if (prop in src) {
result[prop] = src[prop]

@@ -34,0 +34,0 @@ }

{
"name": "pick-by-alias",
"version": "1.1.0",
"version": "1.1.1",
"description": "Pick properties by aliases",

@@ -5,0 +5,0 @@ "main": "index.js",

# pick-by-alias [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)
Pick object properties by a list of aliases. May not sound as a great idea for API design, but that is really useful to avoid remembering exact option names from user point.
Pick object properties [by a list of aliases]. Useful to avoid remembering exact option names from user perspective.

@@ -10,3 +10,3 @@ [![npm install pick-by-alias](https://nodei.co/npm/pick-by-alias.png?mini=true)](https://npmjs.org/package/pick-by-alias/)

let options = pick({
let {positions, color, viewport} = pick({
positions: [...],

@@ -17,13 +17,11 @@ color: 'rgba(0, 100, 200, .75)',

}, {
positions: ['positions', 'points', 'data', 'coordinates'],
color: ['colors', 'color', 'stroke'],
viewport: ['viewport', 'viewBox']
positions: 'positions points data coordinates',
color: 'colors color stroke',
viewport: 'viewport viewBox'
})
// options === {positions, color, viewport}
```
### `result = pick(source, aliases)`
### `result = pick(object, properties)`
Return an object with properties picked by the list or dict of `aliases`. The `aliases` are matched in priority order, ie. the names going first are picked. Each alias can be an array or a comma/space-separated string.
Return an object with properties picked by the list or dict with aliases. Aliases are matched in priority order, ie. first matching name is picked. Each alias can be an array or a comma/space-separated string.

@@ -30,0 +28,0 @@ ```js

@@ -51,1 +51,7 @@ 'use strict'

})
t('avoid picking absent props', t => {
t.deepEqual(pick({a: 1, b:2}, 'a b c'), {a: 1, b: 2})
t.end()
})
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