npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@teamteanpm2024/odit-animi-velit

v1.0.5

Published

> Safely flatten a nested JavaScript object.

Downloads

329

Maintainers

shivamkalsi2024shivamkalsi2024

Keywords

classnameiterationcss nestingbabeles7randomESnexttesterwhichMapES6redux-toolkitTypeBoxrequestobjectcommand-lineregexpfast-copyextendnamesperformanceharmonypersistentbootstrap cssparserdependency managerclitesta11yfast-deep-copybrowserrequiretranspilertrimRightapi@@toStringTagstringifierglacierReflect.getPrototypeOfownbootstrap lessvestcryptelbregular expressionreal-timeamazonjsdiffdiffbyteLengtheslint-pluginzodworkflowchromejsxoffsetloadingstreamsArrayBuffer#slicewaapicoercibleterminalexit-codenumberpackage.jsonsequenceexecfullwidthcallboundclassnamesdotenvFloat32ArrayFloat64ArrayAsyncIteratorpropertydescriptorstapestylessharedlook-upmulti-packagestringcolourbeanstalkpatchreact-hook-formurltoStringTagtoArrayi18nes8uninstallform-validationloggingObject.entriessnsinterruptsassignbuffersdefinereadablestreamgetstatusObservablesfile systempostcssstablefind-upgetterreact-testing-libraryajvCSStrimLeftArrayInt32ArraylibphonenumberauthcommandreducematchAllReactiveExtensionschannelratestylemapreducespeedimmerbrowserslistweakmap0ECMAScript 5picomatchmonorepoawswalkingenumerableUint16ArrayequalitycallbindoptimizersuperstructwordbreaktddgroupeventDispatcherqueryargparsedragconfigfunctionregular expressionsflagsECMAScript 7ECMAScript 2018linewrapclonetapRFC-6455mkdirphandlersfull-widthcall-bindstatelessworkerprototypewgetpyyamlshellhashlazyArray.prototype.flatchromiumsanitizepuresymlinkshebangmiddlewareRegExp#flagscoreobjtypeerrorstylinges-shim APIparentcommanderjestlrucloudsearchmetadataconcurrencycurlsqsURLcopyisConcatSpreadablebreakFunction.prototype.nameStreambluebirdyamlless compilerdroppipesymboloptionanimationietostringtagsettertoolsdirqueueflatlooktoobjectlessBigInt64ArraybalancedObservabletypeofslotECMAScript 2020xtermnested cssWebSocketsstartervalidatornpmpackagesiamfunctionalviewautoprefixerparseines2018es5deepcharactergesturesaccessibilitycss variablefindLastIndextypedarraynegativedomArrayBuffersymlinksECMAScript 6fpparsingescaperedactWebSockettacit$.extendrmdirmkdirses2016boundwhatwgpluginsharedarraybufferURLSearchParamspreprocessorcloudwatchArray.prototype.includesrm -rffiltercallcallbackinstallswfmime-dblesscssArray.prototype.flattenwindowstypedarraysjson-schemarapidlogkarmaWeakSetECMAScript 2022descriptoromitpostcss-pluginirq3dutil.inspectargvIteratorECMAScript 2016classesECMAScript 2019Uint8Arrayoncecssutilkeyskinesisvariables in cssjsonschematrimhelperssigtermgetoptoptimistindicatorhas-owndeepcloneweaksetdatespinnerstypescriptwebelectroncodeslanguagearraybufferfast-deep-clonebyteOffsetObject.assignpushmergequotesetImmediatereducercolorvalueECMAScript 3includeshttpsqsfsprivatethrottlehardlinksObject.definePropertyInt8Arrayspringstyled-componentssyntaxerrorresolvevisualObject.getPrototypeOfchaiprefixinspectreactkoreaninput.envuuidtranspileUint8ClampedArrayhooksjwtcontainsdayjsargsinvariantforEachsortcloudformationschemadeep-copyjson-schema-validationbufferes-abstractenderrobustawesomesaucecurriediteratorvalidationuser-streams256ansicolorsidlettyES8limitedfunctionsfpsvaluesstructuredClonecheckformsfseventstaskspecHyBisafecorsyuppreserve-symlinksinternal slotsideefficientserializertouchmimesortederror-handlingtextwrapinferencelastimportfromdependenciesmake direxitwidthbindbundlerSetgetOwnPropertyDescriptormochaagentendpointes2015formattingdescriptionaccessorSymbolduplexconsumewafjson-schema-validatorrdsES5installerString.prototype.matchAllcompilerasciifastcloneminimalsyntaxmodulespositiveelasticacheentriesreact poseES2017columnspolyfillfiletrimEndnativesearchbcryptlistenerswatchingcensorgradients css3rm -frfindupECMAScript 2023compile lessecmascriptpathfigletArray.prototype.findLastIndexhigher-orderbyteECMAScript 2021babel-coreavamkdirshrinkwrapworkspace:*walkObject.valuesmobileprunesomeshimimportexportsameValueZerotrimStartwarningnegative zerostringifyES2020east-asian-widthsanitizationReactiveXastframertyped arrayconnectcall-boundrfc4122momentjapanesetslibfindLastflaghookformdatastructure__proto__stylesheetloggerES2022iseventsformatRegExp.prototype.flagsfolder[[Prototype]]throatmovematchesgetPrototypeOfdebuggerwritablecomparefast-cloneerrormruArray.prototype.findLasthasOwnparentsStreamsArray.prototype.containsarrayupwatchFileproxysetPrototypeOfgetintrinsictermloadbalancingeses-shimsWeakMapcss-in-jsartbatchzeroless csstypebddlintutilityfullauthenticationES2015l10nrangeerrorrm6to5watchwaitStyleSheetconsoleiteratebanneremojiwriteutilsdatacircularlockfilesymbolstypanionjsdomclass-validatorreusearraysestreemoduleencryptionchinesepromisesdebugroute53core-jsES2018eventEmittersuperagentpnpm9opensimpledbthreePushpasswordfastifylengthnopeprotocol-buffersBigUint64ArrayECMAScript 2017extensiondefinePropertyqueueMicrotaskio-tscolumnSymbol.toStringTagprotofastkeycloudtrailcreatescheme-validationES2019fetchairbnbES2016less.jsfixed-widthglobemitcharacterspropArray.prototype.flatMaplinuxs3intrinsicrecursivePromiseRxeslintpluginnodejsoperating-systemeveryformObject.keyssesObject.istakeebsajaxtelephonecollection.es6rgb-0hasOwnPropertyasyncjsonpathslicees6validlimitES2023gdpremrreact-hooksassertsarktypesetstreamreduxbusyeslintconfigquerystringstoragegatewaydynamodbjQueryexpressMicrosoftconstimmutable

Readme

@teamteanpm2024/odit-animi-velit

Safely flatten a nested JavaScript object.

NPM

Commitizen friendly js-standard-style Build Coverage Known Vulnerabilities

Installation

$ npm i @teamteanpm2024/odit-animi-velit

Methods

flatten(obj, [delimiter])

Flattens an object to one level deep. Optionally takes a custom delimiter, otherwise uses . by default. Circular references within the object will be replaced with [Circular].

const { flatten } = require('@teamteanpm2024/odit-animi-velit')

const original = {
    a: {
        b: {
            c: [{
                val: 'one'
            }, {
                val: 'two'
            }],
            d: 'three'
        },
        e: 'four',
    }
}
original.a.b.f = original.a.b
original.a.b.c.push(original.a)

const flat = flatten(original)
/*
{
  'a.b.c.0.val': 'one',
  'a.b.c.1.val': 'two',
  'a.b.c.2': '[Circular]',
  'a.b.d': 'three',
  'a.e': 'four',
  'a.b.f': '[Circular]'
}
*/

const underscoreFlat = flatten(original, '_')
/*
{
  'a_b_c_0_val': 'one',
  'a_b_c_1_val': 'two',
  'a_b_c_2': '[Circular]',
  'a_b_d': 'three',
  'a_e': 'four',
  'a_b_f': '[Circular]'
}
*/

unflatten(obj, [delimiter])

Unflattens an object back to its original nested form. Optionally takes a custom delimiter, otherwise uses . by default. Circular references denoted by [Circular] are treated as Strings.

const { unflatten } = require('@teamteanpm2024/odit-animi-velit')

const original = {
    'a.b.c.0.val': 'one',
    'a.b.c.1.val': 'two',
    'a.b.c.2': '[Circular]',
    'a.b.d': 'three',
    'a.e': 'four',
    'a.b.f': '[Circular]'
}


const unflat = unflatten(original)

/*{
  a:{
    b:{
      c:[
        {
          val:'one'
        },
        {
          val:'two'
        },
        '[Circular]'
      ],
      d:'three',
      f:'[Circular]'
    },
    e:'four'
  }
}*/