1.0.7 • Published 3 years ago

get-object-values v1.0.7

Weekly downloads
11
License
ISC
Repository
github
Last release
3 years ago

getObjectValues

在需要取得多層物件結構的屬性時,可以試試看這個小工具。

輸入被搜尋的物件,跟搜尋的路徑,可以尋找想要的結果並輸出陣列。

若被搜尋的對象是陣列,會顯示出所有搜尋結果。

範例:

const getObjectValues = require('get-object-values');

const input = {
  key: {
    key2: 123,
    others: '456'
  },
  other: [
    { abc:1, other:3 },
    { cdf:1, other:4 }
  ]
}

getObjectValues(input,'key.key2'); // [123]
getObjectValues(input,'other.abc'); // [1, undefined]
getObjectValues(input,'other.cdf'); // [undefined, 1]
getObjectValues(input,'other.other'); // [3, 4]
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago