appolo-utils
Advanced tools
Comparing version 0.0.45 to 0.0.46
@@ -5,3 +5,3 @@ "use strict"; | ||
static enumNames(enm) { | ||
let res = [], keys = Object.keys(enm), i = 0, len = keys.length; | ||
let res = [], keys = Object.keys(enm || {}), i = 0, len = keys.length; | ||
for (; i < len; i++) { | ||
@@ -16,3 +16,3 @@ let key = keys[i]; | ||
static enumValues(enm) { | ||
let res = [], keys = Object.keys(enm), i = 0, len = keys.length; | ||
let res = [], keys = Object.keys(enm || {}), i = 0, len = keys.length; | ||
for (; i < len; i++) { | ||
@@ -19,0 +19,0 @@ let key = keys[i]; |
export class Enums { | ||
public static enumNames(enm: any): string[] { | ||
let res = [], keys = Object.keys(enm), i = 0, len = keys.length; | ||
let res = [], keys = Object.keys(enm || {}), i = 0, len = keys.length; | ||
@@ -17,3 +17,3 @@ for (; i < len; i++) { | ||
public static enumValues<T>(enm: any): T[] { | ||
let res = [], keys = Object.keys(enm), i = 0, len = keys.length; | ||
let res = [], keys = Object.keys(enm || {}), i = 0, len = keys.length; | ||
@@ -20,0 +20,0 @@ for (; i < len; i++) { |
@@ -23,3 +23,3 @@ "use strict"; | ||
static isEmpty(obj) { | ||
return Object.keys(obj).length === 0; | ||
return Object.keys(obj || {}).length === 0; | ||
} | ||
@@ -32,3 +32,3 @@ static cloneFast(obj) { | ||
let arg = args[i]; | ||
let keys = Object.keys(arg); | ||
let keys = Object.keys(arg || {}); | ||
for (let j = 0, len2 = keys.length; j < len2; j++) { | ||
@@ -46,3 +46,3 @@ let key = keys[j]; | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
@@ -58,3 +58,3 @@ let key = keys[i], value = obj[key]; | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
@@ -68,3 +68,3 @@ let key = keys[i]; | ||
let output = {}; | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
for (let i = 0, length = keys.length; i < length; i++) { | ||
@@ -90,5 +90,8 @@ let key = keys[i], item = obj[key]; | ||
let out = {}; | ||
obj = obj || {}; | ||
for (let i = 0; i < pick.length; i++) { | ||
let key = pick[i]; | ||
out[key] = obj[key]; | ||
if (key in obj) { | ||
out[key] = obj[key]; | ||
} | ||
} | ||
@@ -95,0 +98,0 @@ return out; |
@@ -29,3 +29,3 @@ import {Arrays} from "./arrays"; | ||
public static isEmpty(obj: { [index: string]: any }): boolean { | ||
return Object.keys(obj).length === 0 | ||
return Object.keys(obj || {}).length === 0 | ||
} | ||
@@ -41,3 +41,3 @@ | ||
let arg = args[i]; | ||
let keys = Object.keys(arg); | ||
let keys = Object.keys(arg || {}); | ||
for (let j = 0, len2 = keys.length; j < len2; j++) { | ||
@@ -58,3 +58,3 @@ let key = keys[j]; | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
@@ -76,3 +76,3 @@ for (let i = 0, len = keys.length; i < len; i++) { | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
@@ -92,3 +92,3 @@ for (let i = 0, len = keys.length; i < len; i++) { | ||
let keys = Object.keys(obj); | ||
let keys = Object.keys(obj || {}); | ||
@@ -121,5 +121,8 @@ for (let i = 0, length = keys.length; i < length; i++) { | ||
let out: any = {}; | ||
obj = obj || {} as T; | ||
for (let i = 0; i < pick.length; i++) { | ||
let key = pick[i]; | ||
out[key] = obj[key]; | ||
if(key in obj){ | ||
out[key] = obj[key]; | ||
} | ||
} | ||
@@ -126,0 +129,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"main": "./index.js", | ||
"version": "0.0.45", | ||
"version": "0.0.46", | ||
"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
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
102235
1843