# hoover
The standard Jsonic syntax only supports standard JSON value
keywords: true, false, null.
Wouldn't it be nice to have undefined, Infinity, NaN as well?
And while we're at it, how about recognizing literal /regexp/
syntax, and ISO (2021-03-19T17:15:51.845Z) dates?
The hoover plugin will do this for you!
This is a good plugin to copy and extend if you just want to add some "magic" values to your source data.
# Usage
To use the plugin, require or import the module path: jsonic/plugin/hoover:
// Node.js
let { Hoover } = require('jsonic/plugin/hoover')
// Web
import { Hoover } from 'jsonic/plugin/hoover'
(The convention for loading modules that are Jsonic plugins is to deconstruct: { PluginName } )
Once loaded, parse your source data as normal.
# Quick example
let { Hoover } = require('jsonic/plugin/hoover') // or import
let extra = Jsonic.make().use(Hoover)
extra('a:NaN') // === {"a": NaN}
# Syntax
The standard Jsonic syntax remains available, with the following extensions:
# Hoover value keywords
undefinedNaNInfinity(optional prefix+or-)
# Regular Expressions
Characters between '/' and '/' are converted to a RegExp object.
/a/// === new RegExp('a')/\//g// === new RegExp('\/','g')
# ISO Dates
Unquoted text that matches the ISO date format is converted into a Date object.
when: 2021-03-19T17:15:51.845Z // == new Date('2021-03-19T17:15:51.845Z')
# Options
This plugin has no options.
# Implementation
The source code for this plugin is
here: plugin/hoover.ts.
TODO - discuss