0.2.0 • Published 5 years ago

jslob v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

JSLOB

JS Large OBject - The lazy way to work with JSON that won't fit in memory

Status: Alpha. Working but not stable.

Usage

const JSLOB = require('jslob')()

!async function smallExample(){
	let jslob = await JSLOB.parse('{"foo":"bar"}')
	let output = await JSLOB.stringify(jslob)
	console.log(output) // {"foo":"bar"}
	console.log(await jslob.foo) //bar
	}()

!async function bigExample(){
	let jslob = await JSLOB.parse(fs.createReadStream('package.json'))
	console.log(await jslob.dependencies.jslob)
	JSLOB.streamify(jslob).on("data",chunk=>console.log(chunk))
	}()

Features / API

FeatureDescriptionStatusAPI
Parse StringParse a (potentially huge) JSON stringWorkingawait JSLOB.parse('{}')
Parse StreamParse a (potentially huge) JSON streamWorkingawait JSLOB.parse(readable)
String OutString out JSON from a JSLOBWorkingawait JSLOB.stringify(jslob)
Stream OutStream out JSON from a JSLOBWorkingJSLOB.streamify(jslob)
GettersTransparently get propertiesWorkingjslob.foo //bar
SettersTransparently set propertiesTODOjslob.foo = "baz"
Iterators+Enumerate, iterate, splat, etcTODOJSLOB.entries(jslob) & more
DestroyManually clean up expired objectsTODOJSLOB.del(jslob)
GCAutomatically clean up expired objectsNot currently possibleN/A
StorageUse any leveldown-compliant storageUntestedconst JSLOB = require('jslob')({leveldown:...})
Type-mutating property re-useThe following JSON may return unexpected resultsTODO{"foo":1,"foo":{"x":2}}