gun/src/valid.js
Mark Nadal 638c2c3c23 have unbuild function wrap to prevent scope leaks & allow RETURN hehehe so I can reject @bmatusiak 's lS change O:) O:) I love you you're a hero!
later with @bmatusiak check sea.then for '../gun.js' vs '../' vs ...
note: src/index -> core.js
TODO: something about WebRTC candidates hitting ack decrement limits?
2024-01-17 10:13:00 -08:00

18 lines
712 B
JavaScript

;(function(){
// Valid values are a subset of JSON: null, binary, number (!Infinity), text,
// or a soul relation. Arrays need special algorithms to handle concurrency,
// so they are not supported directly. Use an extension that supports them if
// needed but research their problems first.
module.exports = function(v){
// "deletes", nulling out keys.
return v === null ||
"string" === typeof v ||
"boolean" === typeof v ||
// we want +/- Infinity to be, but JSON does not support it, sad face.
// can you guess what v === v checks for? ;)
("number" === typeof v && v != Infinity && v != -Infinity && v === v) ||
(!!v && "string" == typeof v["#"] && Object.keys(v).length === 1 && v["#"]);
}
}());