appolo-utils
Advanced tools
Comparing version 0.0.42 to 0.0.43
@@ -54,3 +54,3 @@ import {Arrays} from "./arrays"; | ||
public static isFunction(obj: any): boolean { | ||
public static isFunction(obj: any): obj is Function { | ||
return !!(obj && obj.constructor && obj.call && obj.apply); | ||
@@ -57,0 +57,0 @@ }; |
@@ -52,2 +52,11 @@ "use strict"; | ||
} | ||
static clone(obj) { | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
let key = keys[i]; | ||
output[key] = obj[key]; | ||
} | ||
return output; | ||
} | ||
static compact(obj) { | ||
@@ -54,0 +63,0 @@ let output = {}; |
@@ -67,2 +67,17 @@ export class Objects { | ||
public static clone<T>(obj: T): T { | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
let key = keys[i]; | ||
output[key] = obj[key] | ||
} | ||
return output as any; | ||
} | ||
public static compact(obj: any): any { | ||
@@ -69,0 +84,0 @@ |
@@ -6,2 +6,5 @@ "use strict"; | ||
class Reflector { | ||
static getFnMetadata(symbol, klass, defaultValue) { | ||
return Reflector.getMetadata(symbol, klass, undefined, defaultValue); | ||
} | ||
static getMetadata(symbol, klass, propertyName, defaultValue) { | ||
@@ -23,2 +26,5 @@ let value = Reflect.getOwnMetadata(symbol, klass); | ||
} | ||
static getFnOwnMetadata(symbol, klass, defaultValue) { | ||
return Reflector.getOwnMetadata(symbol, klass, undefined, defaultValue); | ||
} | ||
static getOwnMetadata(symbol, klass, propertyName, defaultValue) { | ||
@@ -25,0 +31,0 @@ let value = Reflect.getOwnMetadata(symbol, klass, propertyName); |
@@ -5,3 +5,9 @@ import {Objects} from "../index"; | ||
export class Reflector { | ||
public static getMetadata<T>(symbol: Symbol | string, klass, propertyName?: string, defaultValue?: T): T { | ||
public static getFnMetadata<T>(symbol: Symbol | string, klass: Function, defaultValue?: T): T { | ||
return Reflector.getMetadata(symbol, klass, undefined, defaultValue); | ||
} | ||
public static getMetadata<T>(symbol: Symbol | string, klass: Function, propertyName?: string, defaultValue?: T): T { | ||
let value = Reflect.getOwnMetadata(symbol, klass); | ||
@@ -14,3 +20,3 @@ | ||
if (Reflect.hasMetadata(symbol, klass)) { | ||
value = Objects.cloneDeep(Reflect.getMetadata(symbol, klass,propertyName)); | ||
value = Objects.cloneDeep(Reflect.getMetadata(symbol, klass, propertyName)); | ||
Reflect.defineMetadata(symbol, value, klass); | ||
@@ -22,3 +28,3 @@ return value; | ||
value = defaultValue; | ||
Reflect.defineMetadata(symbol, value, klass,propertyName); | ||
Reflect.defineMetadata(symbol, value, klass, propertyName); | ||
} | ||
@@ -29,2 +35,6 @@ | ||
public static getFnOwnMetadata<T>(symbol: Symbol | string, klass: any, defaultValue?: T): T { | ||
return Reflector.getOwnMetadata(symbol, klass, undefined, defaultValue); | ||
} | ||
public static getOwnMetadata<T>(symbol: Symbol | string, klass: any, propertyName?: string, defaultValue?: T): T { | ||
@@ -31,0 +41,0 @@ |
@@ -1,2 +0,1 @@ | ||
export class Strings { | ||
@@ -14,3 +13,3 @@ public static stringifyObjectValues(obj: { [index: string]: string | boolean | number }): string { | ||
public static isString(str: any): boolean { | ||
public static isString(str: any): str is String { | ||
return (typeof str === 'string' || str instanceof String); | ||
@@ -17,0 +16,0 @@ } |
@@ -17,3 +17,3 @@ { | ||
"main": "./index.js", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"license": "MIT", | ||
@@ -20,0 +20,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99304
1793