create daemon
This commit is contained in:
66
thrower_daemon/node_modules/nostr-tools/lib/cjs/fakejson.js
generated
vendored
Normal file
66
thrower_daemon/node_modules/nostr-tools/lib/cjs/fakejson.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// fakejson.ts
|
||||
var fakejson_exports = {};
|
||||
__export(fakejson_exports, {
|
||||
getHex64: () => getHex64,
|
||||
getInt: () => getInt,
|
||||
getSubscriptionId: () => getSubscriptionId,
|
||||
matchEventId: () => matchEventId,
|
||||
matchEventKind: () => matchEventKind,
|
||||
matchEventPubkey: () => matchEventPubkey
|
||||
});
|
||||
module.exports = __toCommonJS(fakejson_exports);
|
||||
function getHex64(json, field) {
|
||||
let len = field.length + 3;
|
||||
let idx = json.indexOf(`"${field}":`) + len;
|
||||
let s = json.slice(idx).indexOf(`"`) + idx + 1;
|
||||
return json.slice(s, s + 64);
|
||||
}
|
||||
function getInt(json, field) {
|
||||
let len = field.length;
|
||||
let idx = json.indexOf(`"${field}":`) + len + 3;
|
||||
let sliced = json.slice(idx);
|
||||
let end = Math.min(sliced.indexOf(","), sliced.indexOf("}"));
|
||||
return parseInt(sliced.slice(0, end), 10);
|
||||
}
|
||||
function getSubscriptionId(json) {
|
||||
let idx = json.slice(0, 22).indexOf(`"EVENT"`);
|
||||
if (idx === -1)
|
||||
return null;
|
||||
let pstart = json.slice(idx + 7 + 1).indexOf(`"`);
|
||||
if (pstart === -1)
|
||||
return null;
|
||||
let start = idx + 7 + 1 + pstart;
|
||||
let pend = json.slice(start + 1, 80).indexOf(`"`);
|
||||
if (pend === -1)
|
||||
return null;
|
||||
let end = start + 1 + pend;
|
||||
return json.slice(start + 1, end);
|
||||
}
|
||||
function matchEventId(json, id) {
|
||||
return id === getHex64(json, "id");
|
||||
}
|
||||
function matchEventPubkey(json, pubkey) {
|
||||
return pubkey === getHex64(json, "pubkey");
|
||||
}
|
||||
function matchEventKind(json, kind) {
|
||||
return kind === getInt(json, "kind");
|
||||
}
|
||||
Reference in New Issue
Block a user