We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6e3b72b + c2d36a4 commit 631d3b6Copy full SHA for 631d3b6
index.js
@@ -277,6 +277,23 @@ function sanitize_array(arr,schema){
277
return arr
278
}
279
280
+/**
281
+ * Get only selected keys of array
282
+ * Like select query
283
+ *
284
+ * @param array arr
285
+ * @param array keys
286
+ * @returns array
287
+ */
288
+function get_only(arr, keys) {
289
+ is_array(arr);
290
+ is_array(keys);
291
+ return arr.map((a) => keys.reduce((b, key) => {
292
+ b[key] = a[key];
293
+ return b;
294
+ }, {}))
295
+}
296
+
297
export {
298
is_array,
299
is_num_array,
@@ -297,4 +314,5 @@ export {
314
intersection,
315
difference,
316
sanitize_array,
317
+ get_only,
300
318
};
0 commit comments