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

@finos/legend-shared

Package Overview
Dependencies
Maintainers
4
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finos/legend-shared - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

11

lib/CommonUtils.d.ts

@@ -55,4 +55,15 @@ /**

export declare const pruneNullValues: (obj: Record<PropertyKey, unknown>) => Record<PropertyKey, unknown>;
/**
* Recursively sort object keys alphabetically
*/
export declare const sortObjectKeys: (value: Record<PropertyKey, unknown>) => Record<PropertyKey, unknown>;
/**
* Stringify object shallowly
* See https://stackoverflow.com/questions/16466220/limit-json-stringification-depth
*/
export declare const shallowStringify: (object: unknown) => string;
export declare const generateEnumerableNameFromToken: (existingNames: string[], token: string) => string;
/**
* NOTE: This is a small tool to workaround Typescript strictness check with the flag --noUncheckedIndexedAccess enabled
*/
export declare const getNullableFirstElement: <T>(array: T[]) => T | undefined;

@@ -59,0 +70,0 @@ /**

31

lib/CommonUtils.js

@@ -97,4 +97,28 @@ /**

export const pruneNullValues = (obj) => pickBy(obj, (val) => val !== null);
// Stringify object shallowly
// See https://stackoverflow.com/questions/16466220/limit-json-stringification-depth
/**
* Recursively sort object keys alphabetically
*/
export const sortObjectKeys = (value) => {
const _sort = (obj) => {
if (Array.isArray(obj)) {
return obj.map(sortObjectKeys);
}
else if (typeof obj === 'object') {
const oldObj = obj;
const newObj = {};
Object.keys(oldObj)
.sort((a, b) => a.localeCompare(b))
.forEach((key) => {
newObj[key] = _sort(oldObj[key]);
});
return newObj;
}
return obj;
};
return _sort(value);
};
/**
* Stringify object shallowly
* See https://stackoverflow.com/questions/16466220/limit-json-stringification-depth
*/
export const shallowStringify = (object) => JSON.stringify(object, (key, val) => key && val && typeof val !== 'number'

@@ -119,2 +143,5 @@ ? Array.isArray(val)

};
/**
* NOTE: This is a small tool to workaround Typescript strictness check with the flag --noUncheckedIndexedAccess enabled
*/
export const getNullableFirstElement = (array) => array.length ? array[0] : undefined;

@@ -121,0 +148,0 @@ /**

2

lib/package.json
{
"name": "@finos/legend-shared",
"version": "5.0.0",
"version": "5.0.1",
"description": "Legend Studio shared utilities and helpers",

@@ -5,0 +5,0 @@ "keywords": [

{
"name": "@finos/legend-shared",
"version": "5.0.0",
"version": "5.0.1",
"description": "Legend Studio shared utilities and helpers",

@@ -5,0 +5,0 @@ "keywords": [

@@ -178,4 +178,30 @@ /**

// Stringify object shallowly
// See https://stackoverflow.com/questions/16466220/limit-json-stringification-depth
/**
* Recursively sort object keys alphabetically
*/
export const sortObjectKeys = (
value: Record<PropertyKey, unknown>,
): Record<PropertyKey, unknown> => {
const _sort = (obj: unknown): unknown => {
if (Array.isArray(obj)) {
return obj.map(sortObjectKeys);
} else if (typeof obj === 'object') {
const oldObj = obj as Record<PropertyKey, unknown>;
const newObj: Record<PropertyKey, unknown> = {};
Object.keys(oldObj)
.sort((a, b) => a.localeCompare(b))
.forEach((key) => {
newObj[key] = _sort(oldObj[key]);
});
return newObj;
}
return obj;
};
return _sort(value) as Record<PropertyKey, unknown>;
};
/**
* Stringify object shallowly
* See https://stackoverflow.com/questions/16466220/limit-json-stringification-depth
*/
export const shallowStringify = (object: unknown): string =>

@@ -210,2 +236,5 @@ JSON.stringify(object, (key, val) =>

/**
* NOTE: This is a small tool to workaround Typescript strictness check with the flag --noUncheckedIndexedAccess enabled
*/
export const getNullableFirstElement = <T>(array: T[]): T | undefined =>

@@ -212,0 +241,0 @@ array.length ? array[0] : undefined;

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