From f400333f0c26bb19ee4cc5f2a122bbe0cb43f380 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Aug 2020 14:22:07 +0900 Subject: [PATCH] type given.map --- src/index.ts | 3 ++- src/types.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ebf3060..1ca6c5c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import Stringable from "./objects/Stringable" import Numberable from "./objects/Numberable" import Mappable from "./objects/Mappable" import Any from "./objects/Any" +import { MapValue } from './types' type Callback = (result: T) => any @@ -41,7 +42,7 @@ array.macro = (key: string, callback: Function) => (Arrayable.prototype[key] = c /** * Create a flooent map. You have access to [everything from the native Map object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map). */ -const map = (value) => new Mappable(value) +const map = (value: MapValue) => new Mappable(value) map.macro = (key: string, callback: Function) => (Mappable.prototype[key] = callback) /** diff --git a/src/types.ts b/src/types.ts index 6be4630..5edbbe0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,5 @@ export type Constructor = new(...args: any[]) => T export type CopyFunction = TFn extends (...a: infer A) => any ? (...a:A) => TR: never + +export type MapValue = { [key: string]: V } | Map | [K, V][] \ No newline at end of file