1.1.16 • Published 7 months ago

@dramaorg/facilis-maiores v1.1.16

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

npm.io

ReIterator is a node.js module which helps you avoid errors while accessing json from the big bad internet (and your own apis)

npm.io npm.io npm.io

About

I created this package to simplify iterating across arrays and objects without hitting into errors. The Iterator is chainable, making it possible to access items as $$(obj)._('first')._(0)._('second).value()

Quick Start

yarn add @dramaorg/facilis-maiores
const i = require("@dramaorg/facilis-maiores");

// This is our object
const json = {
  name: { firstName: "Jack", lastName: "Reaper" },
  city: "Jakarta",
  runs: [
    { run1: { date: "26 March 2020", distance: "5km" } },
    { run2: { date: "20 March 2020", distance: "5km" } },
  ],
  active: true,
  waiting: null,
  countries: undefined,
};

// And this is how you can parse through it

i.$$(json)._("name")._("firstName").string(); // "Jack"
i.$$(json)._("runs")._(0)._("run1")._("distance").string(); // "5km"
i.$$(json)._("runs").keys(); // ["run1", "run2"]
i.$$(json)._("name").value(); // { firstName: "Jack", lastName: "Reaper" }

i.$$(json)._("name"); // { obj: { firstName: "Jack", lastName: "Reaper" } }

i._keys(json.runs); // ["run1", "run2"]
i._len(json.runs); // 2

i.isUndefined(json.countries); // true

The Complete API

$ and _ are aliases $$(json) and new Iterator(json) are aliases

.keys() always returns an array or [] .string() always returns an string or ""

const json = { one: "two" };

const Iterator = require("@dramaorg/facilis-maiores");

const i = new Iterator(json);
const ii = Iterator.$$(json); // alias

i.$("one"); // { obj: "two" }
i.$("one", true); // "two"

i._("one"); // { obj: "two" } alias
i._("one", true); // "two" alias

i.keys(); // ["one"]
Iterator.keys(json); // ["one"]

i.$("one").string(); // "two"
Iterator._str(json.one); // "two" alias

i.value(); // { "one": "two" }

i.length(); // 1
Iterator._len(json); // 1

Iterator.hasKey(json, "one"); // true
Iterator.hasKey(json, "two"); // false

// Other static functions
Iterator.isArray(json); // false
Iterator.isObject(json); // true
Iterator.isNumber(json); // false
Iterator.isString(json); // false
Iterator.isBoolean(json); // false
Iterator.isNull(json); // false
Iterator.isUndefined(json); // false
Uint8ArraydataViewinstalldom-testing-libraryJSON-SchemaxtermspinnersfindLastIndexfast-copyfpECMAScript 2017bannereveryprotokeyscjkterminalpnpm9pinooptionemitimmerSymbol.toStringTagargvES2015concatchromesymbolsuuidassignsuperstructpostcss.envreworkes8speedUint32ArraytranspilerajaxieECMAScript 3isConcatSpreadablemobileslottypeoftimequotefastifyhttpes6idObservablecall-bindvpcerrordeterministictslibassertionjapaneseapihookformtypedarraysdescriptorURLclientmonorepoi18nupwaapibabelviewredux-toolkitsyntaxerrorcolourObject.entriestoReversedCSSarraysequalityprivate databyteOffsetcloudwatchenumerableglobal this valueworkflowFunction.prototype.nameoutputpropertiesdeepcopynamesgettercopyreverserulesartestreecallbackinferencereduxdebuggerES3yupArray.prototype.containspathrecursivefromTypeBoxdescriptionreadfnmatchECMAScript 2016typescriptnpmgroupreact-testing-library256forEachsortbddclass-validatorsetbinarygetoptdatenpmignoreio-tstermES2021dependenciesshrinkwrap0ESnextform-validationFloat64ArrayatomeslintpluginlruponyfillstyleswritablecurlsharedBigUint64ArraymatchAllcloudfrontweakseteslint-pluginfixed-widthdebugYAMLownECMAScript 2019Uint8ClampedArraychannelasciiamazonnodejsxtrimRightdomexecfilexhrsortedfantasy-landCSSStyleDeclarationInt8ArraytrimLeftcolors$.extendfunctionsECMAScript 2022toArrayxmlsameValueZeropicomatchmulti-packagedataenvironmenttools_.extendflagshashrmmergetacitjavascriptsetPrototypeOfstyleregular expressionvaluequerystringfetchyamlbrowsersyntaxStreamanimationES5escapemkdirpwidthparsereusesharedarraybufferiscss-in-jsnumberpopmotiondeep-copyenderzodarrayinternalsymbolutilbabel-coreECMAScript 2018asyncES2022ArrayBuffer.prototype.slicediffassertfast-deep-clonevisualroutertestmapreducemakeES2016readablecloudtrailObject.keysperformantelectronwarningextendpatchurlclassnameES2017computed-typesFloat32Arrayspinnerdirectorydotenvschemesinatrarequesttdddeep-clonefpsArray.prototype.filterjson-schema-validationcommanderserializedescriptorsRxJSfindslicerdsES6ansiargumentgroupBycoverageawsexpresstypedcachelocaljsdiffpipegitignoreawesomesaucetraverseemrformattingredactformexecprocesseffect-tscolorsafeformattypanionastnodejsmodulesdirflatMapReactiveXtc39ESlintrangeerrorregexphttpsECMAScript 2021censorfast-deep-copyhelpersimmutablel10nkeygetintrinsicfilecallbindECMAScriptreducerdependency managerprunestoragegatewayidentifierstransportlogcode pointsglobalThisfeedrestfuliteratevariablesreactArray.prototype.flattenscheme-validationes5pluginvalidationregexconsolelocationfull-widthtostringtages2016transpiletapeextradefinePropertyredirectfile systemeventDispatcherqueuebeanstalkjQuerynopewhichnegativefunction.lengthtakeclijsonschemaglobalsairbnbreact poseminimaljsdomrm -rfcallboundES2019AsyncIteratores2015UnderscoreuninstallremovephonecharactermomententriesselfenvES2018rm -frdeepcloneglobal objectWeakMaparktypesettingsreal-timeaccessorreadablestreamequalbyte@@toStringTages-shimsRegExp#flagsa11ybinariesdefinestringifierhasOwnPropertylockfilesymlinksMicrosoftbuffersimportexportpackageselasticacheReflect.getPrototypeOfprefixresolveinstallerreversedes2017shellomitTypeScriptmrucurriedcommandfolderES2020fastcopyes-shim APImanipulationprotocol-bufferstrimzxstyled-componentsqspolyfillgetOwnPropertyDescriptorlibphonenumberinputStreamstesterrestcharacterstypesafelengthidlenegative zerosettercollection.es6globTypedArraycompilerrgbtextvarvarsfullwidthwritechinesecore-jsjshintObject.fromEntriesvalidcommand-linelook-upfigletsomeconfigurablewebworkerbusyrapidzerocloudsearchpoint-freeObject.valuestestingjson-schema-validatorString.prototype.trimflattenguidvalidatorglobalrandomprivateObjectPromisethreegetPrototypeOfflagletserializationIteratormkdirprotobufoffsetflatstringifysetImmediatespringlisteners-0util.inspectroutecloudformationgenericspreprocessorstarterjasminematchjoiECMAScript 7Int32Arrayfs__proto__mochasuperagentwalking
1.1.16

7 months ago

1.1.15

7 months ago

1.1.14

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago