Skip to content

Commit

Permalink
Merge pull request #2 from suyashvash/main
Browse files Browse the repository at this point in the history
Object to array conversion
  • Loading branch information
Hetarth02 authored Jul 31, 2022
2 parents 74d876d + 8bce004 commit bb6b937
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ npm i @hetarth02/js-array-helpers
In your `package.json` add the following, `"type": "module"`.

```js
import { is_array } from "@hetarth02/js-array-helpers";
import { is_array, object_to_array } from "@hetarth02/js-array-helpers";

let arr = [1, 2];
console.log(is_array(arr)); // true
```

const objectX = {
0:"Apple",
1:"Microsoft",
2:"Google"
}

console.log(object_to_array(objectX)) // [ 'Apple', 'Microsoft', 'Google' ]

```
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ function array_frequency(arr) {
return freq_obj;
}

export { is_array, head, tail, in_array, array_filter, array_chunk, array_frequency };
function object_to_array(obj){
let temp=[]
const entries = Object.entries(obj)
entries.forEach(ent => temp.push(ent[1]))
return temp;
}

export { is_array, head, tail, in_array, array_filter, array_chunk, array_frequency,object_to_array };

0 comments on commit bb6b937

Please sign in to comment.