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C,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expectType } from \"ts-expect\";\nimport { flatten } from \"./index\";\n\ndescribe(\"flatten\", () => {\n it(\"should flatten an array\", () => {\n const result = flatten([1, [2, [3, [4, [5]]], 6, [[7], 8], 9], 10]);\n\n expectType<number[]>(result);\n\n expect(result).toStrictEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);\n });\n\n it(\"should work with array-like\", () => {\n const result = flatten(\"test\");\n\n expectType<string[]>(result);\n\n expect(result).toStrictEqual([\"t\", \"e\", \"s\", \"t\"]);\n });\n\n it(\"should work with readonly array\", () => {\n const input = [1, [2, [3, [4]]]] as const;\n const result = flatten(input);\n\n expectType<(1 | 2 | 3 | 4)[]>(result);\n\n expect(result).toStrictEqual([1, 2, 3, 4]);\n });\n\n it(\"should work with arguments\", () => {\n const input = (function() {\n return arguments;\n })();\n const result = flatten(input);\n\n expectType<any[]>(result);\n\n expect(result).toStrictEqual([]);\n });\n\n it(\"should work with mixed types\", () => {\n const fn = (x: string) => x;\n const input = [1, [\"test\", [fn, [true]]]];\n const result = flatten(input);\n\n expectType<(number | string | boolean | typeof fn)[]>(result);\n\n expect(result).toStrictEqual([1, \"test\", fn, true]);\n });\n\n it(\"should work with tuples\", () => {\n const input: [number, [number, number], [number]] = [1, [1, 2], [3]];\n const result = flatten(input);\n\n expectType<number[]>(result);\n\n expect(result).toStrictEqual([1, 1, 2, 3]);\n });\n});\n"]} |