1.7.84 • Published 12 months ago

@zitterorg/corporis-ducimus-est v1.7.84

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@zitterorg/corporis-ducimus-est

Safely flatten a nested JavaScript object.

NPM

Commitizen friendly js-standard-style Build Coverage Known Vulnerabilities

Installation

$ npm i @zitterorg/corporis-ducimus-est

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('@zitterorg/corporis-ducimus-est')

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('@zitterorg/corporis-ducimus-est')

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'
  }
}*/
hardlinksxhrperformantcss-in-jsinferencelook-upkeyes5schemefseventscryptodeletecolorArray.prototype.flattenbannerECMAScript 2018writablestylingresolveawaitqueuepackageconsolematchesomitcolumnsmochaflatlibphonenumbersettingsmetadataclassestypedfindLastIndexRFC-6455[[Prototype]]modulesfastclonefunctionaltypeerrorcss variablePushfast-deep-copyfast-deep-cloneparentsapiespreeString.prototype.matchAlles8stylepyyamlECMAScript 2019fastifyspinnerstoolkitloadingredactdeepReactiveXwatcherassertssqsmkdirprfc4122stableconcatMapcode pointsawsprototypeurlmovetakeefficientrm -rfbatchlimitedCSSvalidationregexes2017tsArray.prototype.findLastIndexassignwritephoneTypeBoxargvSetjsdomcallunicodetextkarmajsmaprm -frWeakSetPromisetelephonedataViewfpsencryptionES7accessorUint8Arraybeanstalkwordwrapintrinsicautoprefixergetintrinsicscheme-validationInt32ArrayECMAScript 2021isConcatSpreadablejwtStreamsquotetoobjectansinodejsECMAScript 2023coerciblelastwatchECMAScript 2016symbolsemojisafehooksarraysinstallflagmoduleconfignested cssprettyopentimesortArray.prototype.flatentriesES3typeUint32Arraynegativefast-clone0positivediffRxroutingECMAScript 2020eventDispatcherreactECMAScript 7fullwidthcorsmergevaluesdeepclonesetsyntaxshebangenumerabledependenciessequencerangeerrormruFloat32ArraystyleguidejoiObservablesserializeparseres-abstractrmdirqsfetchcopylogginggradients cssutilityeventEmittermatchbusyES2017environmentcensorgetasciiargsgroupByregular expressionsuperagentdataform-validation_.extendspeedECMAScript 2015URLextensioncjkSymbolArray.prototype.includesless compilerindicatorgetPrototypeOffast-copyjsonfastcopygroupthroatstreams2chromiumduplexiamequalityloggerreadablestreamsharedcoloureslint-pluginsuperstructhaschinesesideES6YAMLObjectObject.fromEntriesES5trimjQueryuninstallchanneldescriptionbytebindshellmonorepovariables in csseslintES2021private dataec2walkingmixinsprotocol-bufferselectronpackagesflagspolyfillwidthlockfiledebuggerless mixinsemrassertroute53findupweaksethasOwnboundfunctionincludesUint16ArrayviewcollectionestreedeterministicmapreduceUint8ClampedArraymiddlewarefull-widthstreamshttpsameValueZerojestspinnercheckrapidfilevalueclientgraphqltrimRightcall-bounddataviewrouteRegExp#flagsES8namesStreamcharacterslinewrapES2016dependency managerECMAScript 3deepcopyes2018Float64ArraycompilerobjectratedynamodbCSSStyleDeclarationObject.ispostcsstoArrayString.prototype.trimcallbackReflect.getPrototypeOfisMapimmutablevalideventsconsumeargumentSymbol.toStringTagparseES2015ownbrowserlistbyteLengthserializerfunctionshookformexpressionutil.inspectrandomsymlinkpluginfigletES2020workflowhelpersbcryptargparseclassnamesflattensnsruntimereduxexecslotreducerworkerreact-hook-formcommanderarraybufferdefinePropertyiteratorcore-jscryptformatarrayvariablesinstallerreadablefullnameUnderscorequeueMicrotasklruTypeScripteverycss nestingECMAScript 2022dateObject.entriescollection.es6-0negative zerobrowseri18nrmdeep-copyoffsetonceTypedArraytrimStarteslintplugindefinestringifierpackage managercontainsrgbArrayBuffergenericseslintconfig@@toStringTagenvRegExp.prototype.flagsremoveelmMicrosoftworkspace:*createchaiajvpredictablecss lessgloboptimizersliceregexpstringifyauthArray.prototype.flatMapformsURLSearchParamsobjInt8ArrayswfnopetostringtagrequesttestingmaketerminaltrimLeftmulti-packageless.jsbyteOffsetReactiveExtensionsnodeconnecthttpsreal-timelengthdeep-clonechromethrottlea11ypnpm9wraptddyupes-shimsparent.envArrayBuffer#slicecommand-lineperformanceastconcattypesafeglacierrequirecircularstoragegatewaystringshrinkwrapawesomesaucestructuredClonestreamxtermtapeschemaObject.definePropertytypanionbundlingFunction.prototype.nameamazonnativel10ntypespackage.jsondom-testing-libraryebstoolsWebSocketscloudwatchpersistentstylesstyled-componentsimportbluebirdlistenersfiltergetOwnPropertyDescriptorsimpledbeast-asian-widthinvariantsharedarraybufferBigUint64Arraycloudfrontwafstarterhotfile systemio-tsajaxtaskaccessibilityguidemitcompile lessasynctesterelbformattingcomputed-typesjsonpathtouchexpresscurles7rdsairbnbcloudsearch$.extendendervalidateextendsymlinkses2016apolloprunecsswebhasOwnPropertyinESvisualInt16Arraymake dirWebSocketfixed-widthutilitiesArray.prototype.filterinternal slotreact-testing-librarydomfromsetterjavascriptjapanesemkdirrecursivefspreserve-symlinkstestECMAScript 5Object.valuesmimeiees2015higher-ordercloudformationides-shim APIredux-toolkitserializationzeroArray.prototype.findLastsymbolkoreanpromiseratelimitdircacheregular expressionsclassnameidlewgettrimEndjsxwatchingsetImmediateObservablewalkwhatwgassertionsyntaxerrorpipefluxtslibjasminegetoptelasticachebufferslanguageconcurrencyArrayBuffer.prototype.slicepreprocessoroptionauthenticationprefixreplayimportexportpicomatchtypedarrayavavestdatastructuregradients css3lookfind-updayjsclonewatchFilecharacterprotobufECMAScript 2017optimist__proto__findES2022readcall-bindsomeredirectgetterdirectoryArray.prototype.containstoSortedhash
1.7.84

12 months ago

1.7.80

12 months ago

1.7.81

12 months ago

1.7.82

12 months ago

1.7.83

12 months ago

1.7.77

12 months ago

1.7.78

12 months ago

1.7.79

12 months ago

1.7.74

12 months ago

1.7.75

12 months ago

1.7.76

12 months ago

1.7.72

12 months ago

1.7.73

12 months ago

1.6.71

12 months ago

1.6.72

12 months ago

1.4.60

1 year ago

1.3.50

1 year ago

1.3.53

1 year ago

1.3.54

1 year ago

1.3.51

1 year ago

1.3.52

1 year ago

1.3.57

1 year ago

1.3.58

1 year ago

1.3.55

1 year ago

1.3.56

1 year ago

1.3.59

1 year ago

1.3.60

1 year ago

1.6.68

1 year ago

1.6.67

1 year ago

1.3.35

1 year ago

1.6.69

1 year ago

1.3.36

1 year ago

1.3.39

1 year ago

1.3.37

1 year ago

1.3.38

1 year ago

1.6.70

12 months ago

1.5.61

1 year ago

1.5.60

1 year ago

1.5.63

1 year ago

1.5.62

1 year ago

1.5.65

1 year ago

1.3.42

1 year ago

1.5.64

1 year ago

1.3.43

1 year ago

1.5.67

1 year ago

1.3.40

1 year ago

1.5.66

1 year ago

1.3.41

1 year ago

1.3.46

1 year ago

1.3.47

1 year ago

1.3.44

1 year ago

1.3.45

1 year ago

1.3.48

1 year ago

1.3.49

1 year ago

1.3.34

1 year ago

1.3.31

1 year ago

1.3.32

1 year ago

1.3.30

1 year ago

1.3.33

1 year ago

1.3.28

1 year ago

1.3.29

1 year ago

1.3.27

1 year ago

1.2.18

1 year ago

1.2.19

1 year ago

1.2.20

1 year ago

1.2.23

1 year ago

1.2.24

1 year ago

1.2.21

1 year ago

1.2.22

1 year ago

1.2.27

1 year ago

1.2.25

1 year ago

1.2.26

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.1.15

1 year ago

1.2.15

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago