1.0.5 • Published 5 days ago

@teamteanpm2024/odit-animi-velit v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 days ago

@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'
  }
}*/
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
1.0.5

5 days ago

1.0.4

6 days ago

1.0.3

7 days ago

1.0.2

8 days ago

1.0.1

9 days ago

1.0.0

10 days ago