Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

h3lp

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3lp - npm Package Compare versions

Comparing version 1.9.1 to 1.10.0

5

application/object.d.ts
import { Delta, DeltaOptions } from '../domain';
export interface ObjectEqualOptions {
strict?: boolean;
}
export interface IObjectHelper {

@@ -16,5 +19,7 @@ clone(obj: any): any;

createKey(data: any): string;
getKeyProperty(sources: any, alternatives?: string[]): string | undefined;
find(obj: any, predicate: (value: any) => boolean): any;
filter(obj: any, predicate: (value: any) => boolean): any[];
delta(current: any, old?: any, options?: DeltaOptions): Delta;
equal(a: any, b: any, options: ObjectEqualOptions): boolean;
}
import { NormalizeOptions } from '../domain/base';
export interface EqualOptions {
ignoreCase?: boolean;
normalize?: boolean;
}
export interface IStringHelper {

@@ -15,2 +19,3 @@ toString(value: any): string;

isDigit(char: string): boolean;
equal(a: string, b: string, options: EqualOptions): boolean;
}

4

infrastructure/object.d.ts
import { Delta, DeltaOptions } from '../index';
import { IObjectHelper, IHttpHelper, IValidator } from '../application';
import { IObjectHelper, IHttpHelper, IValidator, ObjectEqualOptions } from '../application';
export declare class ObjectHelper implements IObjectHelper {

@@ -15,3 +15,5 @@ private readonly http;

setValue(source: any, name: string[], value: any): boolean;
getKeyProperty(sources: any, alternatives?: string[]): string | undefined;
sort(source: any): any;
equal(a: any, b: any, options: ObjectEqualOptions): boolean;
fromEntries(entries: [string, any][]): any;

@@ -18,0 +20,0 @@ jsonPath(obj: any, path: string): any;

@@ -146,9 +146,45 @@ "use strict";

}
getKeyProperty(sources, alternatives = ['id', 'code', 'name', 'key']) {
const propertiesName = Object.keys(sources).map(p => p.toLowerCase());
for (const alternative of alternatives) {
if (propertiesName.includes(alternative.toLowerCase())) {
return alternative;
}
}
return undefined;
}
sort(source) {
const target = {};
for (const key of Object.keys(source).sort()) {
target[key] = source[key];
if (source[key] === null) {
target[key] = null;
}
else if (Array.isArray(source[key])) {
const propertyKey = this.getKeyProperty(source[key]);
if (propertyKey) {
target[key] = source[key].sort((a, b) => a[propertyKey] > b[propertyKey] ? 1 : -1).map((p) => this.sort(p));
}
else {
target[key] = source[key].map((p) => this.sort(p));
}
}
else if (typeof source[key] === 'object') {
target[key] = this.sort(source[key]);
}
else {
target[key] = source[key];
}
}
return target;
}
equal(a, b, options) {
if (!options.strict) {
const _a = this.sort(a);
const _b = this.sort(b);
return JSON.stringify(_a) === JSON.stringify(_b);
}
else {
return JSON.stringify(a) === JSON.stringify(b);
}
}
fromEntries(entries) {

@@ -155,0 +191,0 @@ if (!Array.isArray(entries)) {

import { NormalizeOptions } from '../domain/base';
import { IStringHelper, IValidator } from '../application';
import { EqualOptions, IStringHelper, IValidator } from '../application';
export declare class StringHelper implements IStringHelper {

@@ -8,2 +8,3 @@ private readonly validator;

replace(string: string, search: string, replace: string): string;
equal(a: string, b: string, options?: EqualOptions): boolean;
concat(values: any[]): any;

@@ -10,0 +11,0 @@ capitalize(str: string): string;

@@ -102,2 +102,15 @@ "use strict";

}
equal(a, b, options = {}) {
if (options.normalize) {
a = this.normalize(a);
b = this.normalize(b);
return a === b;
}
else if (options.ignoreCase) {
return a.toLowerCase() === b.toLowerCase();
}
else {
return a === b;
}
}
concat(values) {

@@ -104,0 +117,0 @@ if (!values || values.length === 0) {

{
"name": "h3lp",
"version": "1.9.1",
"version": "1.10.0",
"description": "Helper for nodeJs",

@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc