extension-props
Advanced tools
Comparing version 0.9.2 to 0.9.3
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var standard_1 = __importDefault(require("./standard")); | ||
var ObjectType_1 = require("./types/ObjectType"); | ||
@@ -15,2 +19,3 @@ exports.ObjectType = ObjectType_1.type; | ||
exports.ClassType = ClassType_1.type; | ||
standard_1.default(); | ||
var OverridingError_1 = require("./errors/OverridingError"); | ||
@@ -17,0 +22,0 @@ exports.OverridingError = OverridingError_1.default; |
@@ -0,1 +1,2 @@ | ||
import {default as standard} from './standard'; | ||
import {extend as extendObject, type as ObjectType} from './types/ObjectType'; | ||
@@ -8,2 +9,4 @@ import {extend as extendArray, type as ArrayType} from './types/ArrayType'; | ||
standard(); | ||
export {default as OverridingError} from './errors/OverridingError'; | ||
@@ -10,0 +13,0 @@ |
declare function getAllPropertyNames(obj: Object): string[]; | ||
declare function getAllPropertyDescriptors(obj: Object): any; | ||
declare function isBlank(v: any): boolean; | ||
declare function isNotBlank(v: any): boolean; | ||
export declare const type: { | ||
getAllPropertyNames: typeof getAllPropertyNames; | ||
getAllPropertyDescriptors: typeof getAllPropertyDescriptors; | ||
isBlank: typeof isBlank; | ||
isNotBlank: typeof isNotBlank; | ||
}; | ||
export declare function extend(): void; | ||
export {}; |
@@ -6,2 +6,3 @@ "use strict"; | ||
var temp; | ||
var i; | ||
if (obj) { | ||
@@ -14,3 +15,3 @@ if (obj.constructor === {}.constructor) | ||
for (var _i = 0, temp_1 = temp; _i < temp_1.length; _i++) { | ||
var i = temp_1[_i]; | ||
i = temp_1[_i]; | ||
if (!result.includes(i)) | ||
@@ -28,8 +29,56 @@ result.push(i); | ||
} | ||
function getAllPropertyDescriptors(obj) { | ||
var result = {}; | ||
var names; | ||
var i, temp; | ||
if (obj) { | ||
if (obj.constructor === {}.constructor) { | ||
names = Object.getOwnPropertyNames(obj); | ||
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { | ||
i = names_1[_i]; | ||
temp = Object.getOwnPropertyDescriptor(obj, i); | ||
if (temp !== undefined) | ||
result[i] = temp; | ||
} | ||
} | ||
else { | ||
try { | ||
while (obj.constructor !== Object) { | ||
names = Object.getOwnPropertyNames(obj); | ||
for (var _a = 0, names_2 = names; _a < names_2.length; _a++) { | ||
i = names_2[_a]; | ||
if (result[i] === undefined || | ||
(i === 'constructor' && result[i].constructor !== {}.constructor)) { | ||
temp = Object.getOwnPropertyDescriptor(obj, i); | ||
if (temp !== undefined) | ||
result[i] = temp; | ||
} | ||
} | ||
obj = Object.getPrototypeOf(obj); | ||
} | ||
} | ||
catch (e) { | ||
// continue regardless of error | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
function isBlank(v) { | ||
return v === undefined || v === null; | ||
} | ||
function isNotBlank(v) { | ||
return v !== undefined && v !== null; | ||
} | ||
exports.type = { | ||
getAllPropertyNames: getAllPropertyNames | ||
getAllPropertyNames: getAllPropertyNames, | ||
getAllPropertyDescriptors: getAllPropertyDescriptors, | ||
isBlank: isBlank, | ||
isNotBlank: isNotBlank | ||
}; | ||
function extend() { | ||
Object.getAllPropertyNames = getAllPropertyNames; | ||
Object.isBlank = isBlank; | ||
Object.isNotBlank = isNotBlank; | ||
} | ||
exports.extend = extend; |
function getAllPropertyNames(obj: Object): string[] { | ||
let result: string[] = []; | ||
let temp: string[]; | ||
let i; | ||
@@ -11,3 +12,3 @@ if (obj) { | ||
temp = Object.getOwnPropertyNames(obj); | ||
for (let i of temp) { | ||
for (i of temp) { | ||
if (!result.includes(i)) | ||
@@ -26,4 +27,49 @@ result.push(i); | ||
function getAllPropertyDescriptors(obj: Object): any { | ||
let result: any = {}; | ||
let names: string[]; | ||
let i, temp; | ||
if (obj) { | ||
if (obj.constructor === {}.constructor) { | ||
names = Object.getOwnPropertyNames(obj); | ||
for(i of names) { | ||
temp = Object.getOwnPropertyDescriptor(obj, i); | ||
if(temp !== undefined) result[i] = temp; | ||
} | ||
} else { | ||
try { | ||
while (obj.constructor !== Object) { | ||
names = Object.getOwnPropertyNames(obj); | ||
for (i of names) { | ||
if (result[i] === undefined || | ||
(i === 'constructor' && result[i].constructor !== {}.constructor)) { | ||
temp = Object.getOwnPropertyDescriptor(obj, i); | ||
if(temp !== undefined) result[i] = temp; | ||
} | ||
} | ||
obj = Object.getPrototypeOf(obj); | ||
} | ||
} catch (e) { | ||
// continue regardless of error | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
function isBlank(v: any): boolean { | ||
return v === undefined || v === null; | ||
} | ||
function isNotBlank(v: any): boolean { | ||
return v !== undefined && v !== null; | ||
} | ||
export const type = { | ||
getAllPropertyNames | ||
getAllPropertyNames, | ||
getAllPropertyDescriptors, | ||
isBlank, | ||
isNotBlank | ||
}; | ||
@@ -33,2 +79,4 @@ | ||
Object.getAllPropertyNames = getAllPropertyNames; | ||
Object.isBlank = isBlank; | ||
Object.isNotBlank = isNotBlank; | ||
} |
@@ -17,2 +17,3 @@ interface String { | ||
interface Array<T> { | ||
includes(searchElement: T, fromIndex?: number): boolean; | ||
equals(v: T[]): boolean; | ||
@@ -63,2 +64,4 @@ virtualGet(i: number): T; | ||
interface ObjectConstructor { | ||
isBlank(v: any): boolean; | ||
isNotBlank(v: any): boolean; | ||
getAllPropertyNames(obj: any): string[]; | ||
@@ -65,0 +68,0 @@ preventOverrideClass(obj: any, classDefinition: any, except?: any[]): boolean; |
{ | ||
"name": "extension-props", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
51826
31
1468