• 查找对象中与param key类似的key

    参数

    • target: object | Map<string, any>
    • key: string | RegExp

    返回 string[]

    // array
    likeKeys([1, 2, 3, 4, 5, 6, 7], '0'); // ['0']
    likeKeys([1, 2, 3, 4, 5, 6, 7, 1, 1, 1, 1, 1, 1], '0'); // ['0', '10']

    // object
    likeKeys({ test: 1, test2: 2, test3: 3 }, 'test'); // ['test', 'test2', 'test3']

    // map
    const map = new Map<string, number | string>([
    ['aa', 1],
    ['bb', 2],
    ['hello', 'world'],
    ]);
    likeKeys(map, /a+|b+/); // ['aa', 'bb']