zkjson 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/db.js +5 -4
  2. package/package.json +1 -1
package/db.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const newMemEmptyTrie = require("./circomlibjs").newMemEmptyTrie
2
2
  const snarkjs = require("snarkjs")
3
- const { indexOf, range, isNil } = require("ramda")
3
+ const { is, indexOf, range, isNil } = require("ramda")
4
4
  const { pad, toSignal, encode, toIndex } = require("./encoder")
5
5
  const Collection = require("./collection")
6
6
 
@@ -280,9 +280,10 @@ class DB {
280
280
  }
281
281
  getID(num) {
282
282
  if (!isNil(num)) {
283
- if (indexOf(+num)(this.ids) !== -1) {
283
+ if (indexOf(num)(this.ids) !== -1) {
284
284
  throw Error("id exists")
285
285
  }
286
+ return num
286
287
  } else {
287
288
  while (indexOf(this.count)(this.ids) !== -1) {
288
289
  this.count++
@@ -291,8 +292,8 @@ class DB {
291
292
  }
292
293
  }
293
294
  async addCollection(num) {
294
- if (!isNil(num) && (Math.round(num) !== +num || Number.isNaN(+num))) {
295
- throw Error("id is not numeric")
295
+ if (!isNil(num) && (!is(Number, num) || Math.round(num) !== num)) {
296
+ throw Error("id is not an integer")
296
297
  }
297
298
  const id = this.getID(num)
298
299
  const col = await this.tree.find(id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zkjson",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Zero Knowledge Provable JSON",
5
5
  "main": "index.js",
6
6
  "license": "MIT",