@ephox/katamari
Advanced tools
Comparing version 2.3.3 to 2.3.4
import { Option } from './Option'; | ||
export declare const keys: (o: {}) => string[]; | ||
export declare const hasOwnProperty: (v: string | number | symbol) => boolean; | ||
export declare const each: <T>(obj: T, f: (value: T[keyof T], key: string, obj: T) => void) => void; | ||
@@ -23,1 +24,5 @@ /** map :: (JsObj(k, v), (v, k, JsObj(k, v) -> x)) -> JsObj(k, x) */ | ||
export declare const size: (obj: {}) => number; | ||
/** get :: (JsObj(k, v), k) -> Option v */ | ||
export declare const get: <T, K extends keyof T>(obj: T, key: K) => Option<T[K]>; | ||
/** has :: (JsObj(k, v), k) -> Bool */ | ||
export declare const has: <T, K extends keyof T>(obj: T, key: K) => boolean; |
@@ -7,2 +7,3 @@ import { Option } from './Option'; | ||
export var keys = Object.keys; | ||
export var hasOwnProperty = Object.hasOwnProperty; | ||
export var each = function (obj, f) { | ||
@@ -76,2 +77,10 @@ var props = keys(obj); | ||
}; | ||
/** get :: (JsObj(k, v), k) -> Option v */ | ||
export var get = function (obj, key) { | ||
return has(obj, key) ? Option.some(obj[key]) : Option.none(); | ||
}; | ||
/** has :: (JsObj(k, v), k) -> Bool */ | ||
export var has = function (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
}; | ||
//# sourceMappingURL=Obj.js.map |
{ | ||
"name": "@ephox/katamari", | ||
"version": "2.3.3", | ||
"version": "2.3.4", | ||
"description": "Basic data type library", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -9,2 +9,4 @@ import { Option } from './Option'; | ||
export const hasOwnProperty = Object.hasOwnProperty; | ||
export const each = function <T> (obj: T, f: (value: T[keyof T], key: string, obj: T) => void) { | ||
@@ -85,1 +87,12 @@ const props = keys(obj); | ||
}; | ||
/** get :: (JsObj(k, v), k) -> Option v */ | ||
export const get = function <T, K extends keyof T> (obj: T, key: K): Option<T[K]> { | ||
return has(obj, key) ? Option.some(obj[key]) : Option.none(); | ||
}; | ||
/** has :: (JsObj(k, v), k) -> Bool */ | ||
export const has = function <T, K extends keyof T> (obj: T, key: K): boolean { | ||
return hasOwnProperty.call(obj, key); | ||
}; |
Sorry, the diff of this file is not supported yet
795449
442
13248