Skip to content

Instantly share code, notes, and snippets.

@nedjs
nedjs / nodet
Created October 12, 2023 20:33
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { spawn } = require("child_process");
const FgRed = "\x1b[31m"
const Reset = "\x1b[0m"
const args = process.argv.slice(2);
@nedjs
nedjs / Radix.ts
Last active October 26, 2022 20:56
/**
* Converts numbers to and from Radix64
* "inspired" by https://stackoverflow.com/questions/6213227/fastest-way-to-convert-a-number-to-radix-64-in-javascript#answer-6573119
* but converted to use bigint and made into typescript.
*/
export class Radix {
private _rixsize = BigInt(this._rixits.length);
public constructor(
@nedjs
nedjs / package-lock.json
Created February 19, 2020 18:58
TS Node
{
"name": "elastic-search-stream",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
@nedjs
nedjs / object_diff.js
Created February 19, 2020 18:45
Diffing objects in typescript
// TODO: array support is meh
// object reference to represent no change was made.
const NO_CHANGE: any = Object.freeze({});
const objToString = ({}).toString;
const typeMap: { [key: string]: string } = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
@nedjs
nedjs / PromiseThrottle.d.ts
Last active October 18, 2023 16:04
A simple throttling utility which delays execution of promises using either time or concurrent requests
/**
Use by simply calling the `wrap` on the function which returns promises. For instance
function callApiAndReturnPromise() {
...
}
might become
const promiseThrottle = require('./promiseThrottle');