infer-values

1.0.2 • Public • Published

Beware, It is really trivial and slow

JSON.parse(JSON.stringify()) is not really fast or efficient, but stringify has convenient replacer parameter

Useful for converting request query values to integers and booleans

Lets say you have lots of stuff in query

app.get('/query', (req, res) => res.send(req.query))
app.get('/infer', (req, res) => res.send(inferValues(req.query)))
GET /sign?url=https%3A%2F%2Fsource.unsplash.com%2Ffeatured%2F500x500&resize%5Bwidth%5D=200&resize%5Bheight%5D=150&resize%5BwithoutEnlargement%5D=true&output%5Bquality%5D=6&output%5Bformat%5D=jpeg

will output

{
  "url": "https://source.unsplash.com/featured/500x500",
  "resize": {
    "width": "200",
    "height": "150",
    "withoutEnlargement": "true"
  },
  "output": {
    "quality": "6",
    "format": "jpeg"
  }
}

GET /infer?...

{
  "url": "https://source.unsplash.com/featured/500x500",
  "resize": {
    "width": 200,
    "height": 150,
    "withoutEnlargement": true
  },
  "output": {
    "quality": 6,
    "format": "jpeg"
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i infer-values

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

2.13 kB

Total Files

4

Last publish

Collaborators

  • gcoda