File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,34 @@ npm i @hetarth02/js-array-helpers
1313
1414In your ` package.json ` add the following, ` "type": "module" ` .
1515
16+ ### is_array()
1617``` js
17- import { is_array , object_to_array } from " @hetarth02/js-array-helpers" ;
18+ import { is_array , object_to_array , search_in_array } from " @hetarth02/js-array-helpers" ;
1819
1920let arr = [1 , 2 ];
2021console .log (is_array (arr)); // true
22+ ```
2123
24+ ### object_to_array
25+ ``` js
2226 const objectX = {
2327 0 : " Apple" ,
2428 1 : " Microsoft" ,
2529 2 : " Google"
2630 }
2731
28- console .log (object_to_array (objectX)) // [ 'Apple', 'Microsoft', 'Google' ]
32+ console .log (object_to_array (objectX)) // [ 'Apple', 'Microsoft', 'Google' ]
33+
34+ ```
35+
36+ ### search_in_array
37+ ``` js
38+
39+ const mang = [ ' Microsoft' ,' apple' ,' netflix' ,' Google' ]
40+
41+ const result = search_in_array (" app" ,mang);
42+
43+ console .log (result); // ['apple']
44+
2945
3046```
Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ function get_all_indexes(arr, val) {
9393 return indexes ;
9494}
9595
96+ function search_in_array ( query , array ) {
97+ return array . filter ( item => item . toLowerCase ( ) . search ( query . toLowerCase ( ) ) !== - 1 )
98+ }
99+
96100export {
97101 head ,
98102 tail ,
@@ -103,4 +107,5 @@ export {
103107 array_frequency ,
104108 object_to_array ,
105109 get_all_indexes ,
110+ search_in_array ,
106111} ;
You can’t perform that action at this time.
0 commit comments