New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hyurl/utils

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyurl/utils - npm Package Compare versions

Comparing version 0.1.26 to 0.1.27

2

flatObject.d.ts

@@ -12,3 +12,3 @@ declare type OmitChildrenNodes<T> = Pick<T, {

*/
export default function flatObject<T extends object>(obj: T, depth?: number): OmitChildrenNodes<T> & Record<string | symbol, any>;
export default function flatObject<T extends object>(obj: T, depth?: number, flatArray?: boolean): OmitChildrenNodes<T> & Record<string | symbol, any>;
export {};

@@ -14,7 +14,7 @@ "use strict";

*/
function flatObject(obj, depth = 1) {
return flatDeep({}, obj, "", 0, depth);
function flatObject(obj, depth = 1, flatArray = false) {
return flatDeep({}, obj, "", 0, depth, flatArray);
}
exports.default = flatObject;
function flatDeep(carrier, source, field, depth, maxDepth) {
function flatDeep(carrier, source, field, depth, maxDepth, flatArray) {
let isArr;

@@ -35,3 +35,3 @@ let isObj;

else {
flatDeep(carrier, value, field ? `${field}.${key}` : key, depth, maxDepth);
flatDeep(carrier, value, field ? `${field}.${key}` : key, field ? depth + 1 : depth, maxDepth, flatArray);
}

@@ -41,5 +41,10 @@ });

else if (isArr) {
for (let i = 0, len = source.length; i < len; ++i) {
flatDeep(carrier, source[i], field ? `${field}.${i}` : String(i), depth + 1, maxDepth);
if (flatArray) {
for (let i = 0, len = source.length; i < len; ++i) {
flatDeep(carrier, source[i], field ? `${field}.${i}` : String(i), field ? depth - 1 : depth, maxDepth, flatArray);
}
}
else if (depth > 0) {
carrier[field] = source;
}
}

@@ -46,0 +51,0 @@ return carrier;

{
"name": "@hyurl/utils",
"version": "0.1.26",
"version": "0.1.27",
"description": "Utility functions of HyURL collection.",

@@ -5,0 +5,0 @@ "main": "libs/index.js",

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