1.2.20 • Published 1 year ago

@devtea2027/consequatur-impedit-fugit-odio v1.2.20

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@devtea2027/consequatur-impedit-fugit-odio

Safely flatten a nested JavaScript object.

NPM

Commitizen friendly js-standard-style Build Coverage Known Vulnerabilities

Installation

$ npm i @devtea2027/consequatur-impedit-fugit-odio

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('@devtea2027/consequatur-impedit-fugit-odio')

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('@devtea2027/consequatur-impedit-fugit-odio')

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'
  }
}*/
typeerrorrequestlesscssStreamsiteratoropenertypeless.jscloudformationaccessibility-0toSortedexecairbnbxdgTypeBoxelmwordbreakexit-codediffsyntaxerrorwordwrapelectronlimitargsrecursivestyleweakmapregexwidthrangeerrorvariables in cssless mixinsawaitconfigcloudsearchutilconfigurableObject.definePropertyentrieslibphonenumbersettingsautoprefixerRxes2018assertspropertiesfast-copyflatMapWeakMapstylesheet[[Prototype]]RxJSweaksetutilitiesiterationbeanstalkimportenumerableregular expressionseventEmittervarsrm -rflaststatecommand-linetsUint8ClampedArraypropertyarraywaitconnectinferencesqsbuffersa11ycssredux-toolkitURLSearchParamseslint-plugingetshrinkwrapdeletees2017Object.getPrototypeOfhigher-ordercmdcoreless compilerelasticachewalkingmatchesreal-timeECMAScript 7timeclassnameSymbolhasOwnpackage.jsonutilitycss-in-jsprocesssequenceponyfillfseventsjwturlsvaluemkdirpbluebirdestreeunicodeArray.prototype.containsbusyJSON-SchemaloggingmonorepoArrayBuffer.prototype.sliceclassestaskterminalcryptoassertforEachvalid__proto__privatevaluesindicatorpasswordhookformfsparserelbBigInt64ArraycallcollectionargumentECMAScript 2022concurrencyjoiapprm -frloadingcss variablereact-hooksstringifyseswhichArrayES2022mergeawsserializationgetoptlaunchMicrosoftjsdominternal slotboundwhatwgjavascriptcall-boundcurlmake dirassertiones-abstractexecutablestylinghashsameValueZerointerruptsAsyncIteratoroutputworkflowloadbalancingrapidmrufast-deep-clonemkdirsinspectbootstrap cssmapreducefile systemfastcopyfindLastFloat32ArrayECMAScript 6uninstallES2019formsartObjectsafeqsES2020arraysglobalsefficientECMAScript 2021typedarraysjsonpathidletypesafergbincludespathhttproute53bundlerObservablesquerystringsomevariablesECMAScript 3uuidES6chineseoptimizerPromiselengthajaxiteratees-shim APItrimEndclass-validatortaploggershebangcontainsomit0byteOffsetspinnersECMAScript 5pushmiddlewareemojiObject.valuesauthenticationreact-testing-libraryargparseReactiveExtensionsratelimitlistenersequalitybytestringttycheckstreamtoStringTagdataViewsigtermprotofpsPushamazonvisualprotocol-bufferseslintpluginES2023flaglazytraversegradients cssnopenumberWeakSetpyyamlfilter$.extenddefinevpcconcatMapspawnwrapexegroupByrequireESnextregularinvariantglobnegativebyteLengthdeep-copynativesymlinkimportexporttypanionstyled-componentsenvArray.prototype.flatMapEStelephoneURLprefixformatremovedirectoryclonemacosFunction.prototype.namefullwidthtypedarraytypesmobileES5toolsperformantwebcallbindprogresscjkfindWebSocketsduplexzodECMAScript 2019walkrestfast-cloneglacierie@@toStringTageslintconfigxtermdom-testing-libraryviewkinesisdeterministicpersistentescapeopenRegExp.prototype.flagslogerrorjshintobjectmomentcomputed-typesfunctionrouterparentssignalsjestkeysfromqueuehas-ownstyleguideredactenvironmentssuperagentString.prototype.trimbootstrap lessdebugglobalreadextendpackage managerreduxwritableFloat64ArrayfluxrandomguiddependenciesflatmatchAlliamObject.keysArray.prototype.includessymbolhookssortstdlibtrimLefteverystartreducerfindupemrstableRFC-6455ES2015parseJSONCSSperformancesymbolscommanderdeep-clonemimeECMAScript 2016warningfind-upcloudfrontsiginterror-handlingoptionwatchbreakes2015Array.prototype.flatparentObject.isRegExp#flagschromiumi18nTypeScripthasOwnPropertyserializethroatconsoleTypedArraysharedarraybufferxhrcreateavagetOwnPropertyDescriptortc39Uint32Arrayscheme-validationenderworkspace:*argvtyped arrayirqmapcompile lessfunctionscolormochaMaptddmixinsqueryfunctionaltextwgetmatchcolorseventssetArray.prototype.findLasteses2016intrinsictapelinewrapoffsetes8definePropertygetintrinsicexpresspreprocessorinstallersignalimmutablejapaneseclassnamesArrayBufferideditorsyntaxES7Object.fromEntriesinternales7Object.assignpositiveautoscalingstructuredCloneflagsinastdropeast-asian-widthpostcss-pluginbannerstatuspackageses6ES8installproxyrobustmetadataslicepostcssdescriptorUint8ArrayshimhasworkergetterchannelwindowsSymbol.toStringTagarktypewritezerosharedmimetypesschemedomexpressionstatelesscommandpipefilejsdiffargumentscall-bindInt32Arraytesterexitgdprkeystoragegatewaycss lessphonewatchingStyleSheetrdsyupes5linklanguageBigUint64ArraykarmalookstylesECMAScript 2018side.envimmerbrowserslistkoreanfastclonepreserve-symlinksnodeprettycolumnslivefulll10nqueueMicrotaskpatchreusenameapifast-deep-copyfastbcryptpluginvalidaterestfulcode pointsInt16ArrayArray.prototype.flattenconsumeYAMLtermlessdatasimpledbencryptionebsminimalrmless cssdescriptionjQueryecmascriptnodejstypedmkdirStreamgetPrototypeOfconcatregular expressionreplayopenscloudtrailsetterArray.prototype.filtershellrateserializersinatranpmdayjsemitschemapromisepruneownendpointpredictableswftoobjectresolvedotenvassignsnsidentifierscolumnhttpsawesomesaucegroupmodulestrimtestingflattentostringtagECMAScript 2017charactersArray.prototype.findLastIndexextraObject.entriesansiisConcatSpreadablecensorhelpersHyBipropECMAScript 2023fastifyreducecoerciblelinuxtakethrottlestreams2setImmediatelimitedSetbindsearchbuffercopyString.prototype.matchAllslotajvbatchcomparegradients css3rfc4122polyfilltrimRighttouchframeworkrmdirnamespromisesfull-widthWebSocketlockfileformlook-upshamfindLastIndexdescriptorsupstreamscodesurlES2018childfixed-widthwatchFilestringifierES2017wafspeedCSSStyleDeclarationtypescriptIteratorcallbackreact-hook-formprivate datamoveauthsuperstructprotobufjsxoptimistcharacterwatchercorscolourreacttestReflect.getPrototypeOfbrowserclifigletfolderfetchquotejsonregexptslibxdg-opendeepcopyvalidationasciisymlinksinputruntimeutil.inspectdirjasmineObservablepnpm9handlerschaipicomatchtrimStarttoolkitprototypees-shimsmulti-packagearraybuffermime-dbjsES2016sortedcollection.es6specpackagecrypthotoperating-systemdynamodbhardlinksdebuggerECMAScript 2015formattingnegative zeroReactiveXchromeagenteventDispatcher256io-tscloudwatchlruES3
1.2.19

1 year ago

1.2.20

1 year ago

1.2.18

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.2.14

1 year ago

1.2.15

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago