mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 19:04:46 +00:00
feat(monorepo): migrate vue packages and apply oxlint refactors
This commit is contained in:
@@ -5,22 +5,22 @@ import type { Arrayable } from '../../types';
|
||||
* @name pick
|
||||
* @category Objects
|
||||
* @description Returns a partial copy of an object containing only the keys specified
|
||||
*
|
||||
*
|
||||
* @param {object} target - The object to pick keys from
|
||||
* @param {Arrayable<keyof Target>} keys - The keys to pick
|
||||
* @returns {Pick<Target, Key>} The new object with the specified keys picked
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* pick({ a: 1, b: 2, c: 3 }, 'a') // => { a: 1 }
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) // => { a: 1, b: 2 }
|
||||
*
|
||||
*
|
||||
* @since 0.0.3
|
||||
*/
|
||||
export function pick<Target extends object, Key extends keyof Target>(
|
||||
target: Target,
|
||||
keys: Arrayable<Key>
|
||||
keys: Arrayable<Key>,
|
||||
): Pick<Target, Key> {
|
||||
const result = {} as Pick<Target, Key>;
|
||||
|
||||
@@ -31,9 +31,10 @@ export function pick<Target extends object, Key extends keyof Target>(
|
||||
for (const key of keys) {
|
||||
result[key] = target[key];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result[keys] = target[keys];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user