0.0.4 • Published 7 years ago

andn v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

andn (Array notation to dot notation)

Lets you convert array notation to dot notation, and vice versa.

Instructions

npm install andn

NOTE:

Currently (0.0.3) does not work with '' and '' inside key names for arrayToDotNotation, and does not work with '.' inside key names for dotToArrayNotation(if you mix notations). Will fix, eventually.

Currently both functions return -1 on error, unless throwError is set to true

Provides:

arrayToDotNotation(input: string, enforceQuotes: boolean = true, throwError: boolean = false)

dotToArrayNotation(input: string, useSingleQuotes: boolean = false, throwError: boolean = false)

const ANDN = require('./index.js');

console.log(ANDN.arrayToDotNotation("helloworld")); //helloworld
console.log(ANDN.arrayToDotNotation("hello['world']")); //hello.world
console.log(ANDN.arrayToDotNotation("hello['world']['a']")); //hello.world.a
console.log(ANDN.arrayToDotNotation("hello['world'].a")); //hello.world.a

// Not enforcing quotes
console.log(ANDN.arrayToDotNotation("helloworld[0]", false)); //helloworld.0

console.log(ANDN.dotToArrayNotation("helloworld")); //helloworld
console.log(ANDN.dotToArrayNotation("hello.world")); //hello["world"]
console.log(ANDN.dotToArrayNotation("he['llo'].world"), true); //he['llo']['world]
console.log(ANDN.dotToArrayNotation("h.e.l.l.o.w.o.r.l.d")); //h["e"]["l"]["l"]["o"]["w"]["o"]["r"]["l"]["d"]