1.1.3 • Published 13 days ago

@teamteanpm2024/voluptates-iusto-doloremque v1.1.3

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

@teamteanpm2024/voluptates-iusto-doloremque

Safely flatten a nested JavaScript object.

NPM

Commitizen friendly js-standard-style Build Coverage Known Vulnerabilities

Installation

$ npm i @teamteanpm2024/voluptates-iusto-doloremque

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/voluptates-iusto-doloremque')

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/voluptates-iusto-doloremque')

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'
  }
}*/
ES5columnsequenceECMAScript 2020nativecommand-linezerobyteLengthmakeasyncratejslookmime-dbArrayBuffer.prototype.sliceweaksetECMAScript 2021bundlerspringdeep-clonewrapworkspace:*typesratelimitutil.inspectjsonpathautoprefixerchineseerrorextrabatchsliceeditorvaluesreadstringifybuffersopenexeframerloadingtrimStartjoitypescriptpluginuuidstylingString.prototype.trimfixed-widthrequirerecursiveoncetrimLeftforEachupeventEmitterfindLastIndex[[Prototype]]airbnbwalkingstringifiertypesafeArray.prototype.flatMapjson-schemaperformancewatchRxincludesvalidationcallboundobjectfindLastReactiveExtensionslaunchajvReflect.getPrototypeOfmacostapemkdirsphoneviewsanitizeUint16Arrayposepyyamlwaapi256boundreducerclientstyleconcatMapform-validationreact animationArray.prototype.flatgenericsfilehasclass-validatorfunctionstermstableawaitvaluecall-boundIteratorcharacterramdadeletepreserve-symlinksextendprotocol-buffersiteratorpushgetPrototypeOfwarningcolorsbrowserslisthigher-orderObject.entriesmochajQueryflattentimeperformantstylesheetmkdiraccessoresmergeECMAScript 2017mimeyupuser-streamsFloat32Arrayurlsexecnegative zerostreams2wgetastbufferSymbolhooksprocesswatchermulti-packagesignalwatchFileimportflatxtermcolumnsassertarraysArray.prototype.findLastinternal slotregexlook-upsettingsconstcreateECMAScript 7qswalkes-abstractECMAScript 2019groupbootstrap lessgradients css3xhrgroupByclassnamescopychildwritablejsonequalpropertiessanitizationclassnamechannelregular expressionconnectmomentlistenershandlerseslintpluginWeakMappostcss-pluginsetteres2016Int16ArraytelephoneserializationargsformattingTypedArrayes6corsschemeidlelessargvconfigurabledeepcopyschemakeysconfigjsonschemapipecommandershrinkwrappropthrottleless compilerdescriptorsPush6to5dependency managerArray.prototype.containsshellfetchassignparentECMAScript 3eslint-pluginjsxbluebirdformsfantasy-land$.extendchromiumpostcssfromextensioncensorcurrieddifftrimRightcomputed-typesStyleSheetopensESnextquerytspropertyoffsetdataviewtranspileeveryinspectfastcloneiterateAsyncIteratorescapesigterminstallless csstypedcompareless.jstesterxsskarmapoint-freequoteES2023removeStreamsrequestparentsFunction.prototype.namesymlinksmatchAllsigintfast-deep-clonefolderhasOwnJSON-SchemaweakmapRegExp#flagsBigUint64ArraylockfilegetterimmerisponyfilldataObject.getPrototypeOfURLSearchParamsdefaultCSSStyleDeclarationopenerconcatinternalimmutableObjecteast-asian-widthfprangeerrordeterministicprivatecoerciblejapanesecss variableassertionshamstyleguideES2016fulloptimizertoolkitbreakreact posemixinses7.envartdatecryptmimetypesreduceutilsvalidRFC-6455modulechromefunctionalTypeScriptsortedsharedprettycorecoloreventsES2021private datametadatatc39dom-testing-librarycommandcallbackhelpersreact-hookspackagestatusfindupECMAScript 5call-bindemitfigletarraybufferstylesduplexexit-codepackage.jsonspinneraccessibilityrfc4122yamles5enumerableconcurrencyvest0frameworkECMAScript 2022fastifyjson-schema-validationapolloexpressloggingObservablesMicrosoftansiefficientspawnwhatwgcore-jsArraysameValueZero3da11yrmdirArray.prototype.findLastIndexpositiveletArray.prototype.includesworkerprogressestreejsdomconsoledompatchoptimistobjtranspilertestingCSScss lesswordwrapspeedenvtacitdirectoryrobustxdg-openbannertouchgraphqlshebanglinewrappurelinkomitnodedirtslibwriteMapnested cssstreamsetregular expressionsthreeexecutablesignalscachecollectionTypeBoxtoSortedbundlingminimalECMAScript 2016windowsreduxgdprsymbolscollection.es6babelflagsdotenvInt8Arrayindicatorrm -frruntimesuperagentcryptoirqstringecmascriptformcloneserializeemojiredactes8libphonenumberrapidpreprocessordependenciesanimationprefixfullwidthappinterruptsparserObject.valuesFloat64Arrayless mixinscompile lessjsdiffstyled-componentsthroatquerystringcss-in-jsRegExp.prototype.flagsspecisConcatSpreadableieweblintloggerfastformatutilitiesarrayentrieslimitedvariables in csssyntaxerrortoStringTagreact-hook-formObject.keyswidthhttpsfilterwaitvarendereslintconfigreact-testing-librarydeepcloneStreamcompilerinvariantregulartrimEndfile systemreal-timeasciiauthES2022dayjsslotjavascriptcjkdescriptorJSONdefinecsslazysharedarraybufferutilharmonycurlpathPromiseECMAScript 2015es2018queuel10nmovetypedarrayString.prototype.matchAllObservablehookformhttpcallcodeswatchingnegativees2017typeofpersistentinstallercmdexpressioncircularargumentregexpObject.fromEntriestypedarraysenvironmentflatMapgetoptargparsematcheseslintrandompasswordinputgetiterationUnderscorestartergradients css_.extendreadablestreamscheme-validationbyteOffsetzodapioutputes2015prunepackagesprototypeArray.prototype.flattenReactiveXreadabledefinePropertyes-shimsttybootstrap cssECMAScript 2023xdgSetpopmotioni18nidtddargumentsRxJStestUint8ArraylruconsumeprotobufgetOwnPropertyDescriptorcode pointsexitflagvalidatorclasseshashcheckmkdirpdroppromisesdebuggerbcryptpolyfillnopelogtoobjectfastcopydeepmonoreposerializerutilitymapES8sortjasmineSymbol.toStringTagredux-toolkitObject.definePropertytostringtagObject.ismiddlewarecolourdescription@@toStringTagfast-copytypeerrordebugvalidatedatastructurehardlinksavastatelessvariablesnamedataViewECMAScript 2018ES2020lesscsspromiseencryptionArray.prototype.filterlastWeakSetsomelanguageajaxfast-deep-copyArrayBuffergesturesECMAScript 6unicodefunctionpicomatchfull-width__proto__ES6limitpnpm9mobilesuperstructjson-schema-validatornumbertakeES2017eventDispatcherbindfast-clonestarttypanionjwtsetPrototypeOfmake dirUint32ArrayWebSocketES2015toArraysymlinkerror-handlingvisualcontainsreactHyBitaskcharactersES2019typenpmObject.assignkoreantoolsintrinsicparsebddtexturltyped arraywebsitefind-upYAMLdeep-copy-0queueMicrotaskArrayBuffer#slicebyteBigInt64ArrayES2018streamslengthfindequalitycss nestingarktypesetImmediatenodejsoptioncallbindnamesgetintrinsiclinuxstructuredClone
1.1.1

15 days ago

1.1.3

13 days ago

1.1.2

14 days ago

1.1.0

16 days ago

1.0.0

16 days ago