GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yowainwright/common-utilities: Simple typed utilities generally written in a functional style for learning and utility 🧰

BranchesTags
Open more actions menu

Latest commit

 

History

1,363 Commits
1,363 Commits

Folders and files

NameName
Last commit message
Last commit date
.changeset
.changeset
 
 
.devcontainer
.devcontainer
 
 
.github
.github
 
 
ops
ops
 
 
scripts
scripts
 
 
svcs
svcs
 
 
u
u
 
 
.codependencerc
.codependencerc
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.oxlintrc.json
.oxlintrc.json
 
 
.shellcheck-legibility.toml
.shellcheck-legibility.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
mise.toml
mise.toml
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Common Utilities

Small, typed TS utilities you can copy w/o adding a JS dep.

[in progress] Common Utilities uses an MCP-first, copy/paste workflow inspired by shadcn/ui.

  1. ask for what you need
  2. review the result
  3. you own the source

Why use it?

  • Fewer security concerns: the copied utility requires no pkg install or dep tree.
  • Fewer tokens: the MCP returns the focused utility, documentation, tests, diff, and provenance you need. You can just use the api as well. The MCP is lang translation only.
  • Fast development: reuse small, tested building blocks instead of reinventing them.

Use the MCP

Ask your MCP client for a TypeScript utility. The response includes:

  • ready-to-copy source
  • a Markdown explanation and usage example
  • a reviewable diff
  • tests and provenance

Review the diff, then copy the files into your project. Your codebase owns the result and future changes are explicit.

Str (Strings)

String conversion, encoding, interpolation, and whitespace helpers.

kebab-to-camel-string

kebabToCamelString(value: string): string;
kebabToCamelStringsInObject(
  value: ObjectOfStrings,
): ObjectOfStrings;

Converts kebab-case text to camelCase. The object helper converts keys and preserves string values.

Usage

kebabToCamelString("test-thing");
// "testThing"

kebabToCamelStringsInObject({ "test-thing": "foo" });
// { testThing: "foo" }

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

rot13: (value: string) => string

Applies the ROT13 substitution to ASCII letters and leaves other characters unchanged.

Usage

rot13("Hello Rot13 is awesome!");
// "Uryyb Ebg13 vf njrfbzr!"

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

snake-to-camel-case: (value: string) => string

Converts a snake_case string to camelCase.

Usage

snakeToCamelCase("camel_case_string");
// "camelCaseString"

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

string-interpolation

stringInterpolation(
  value: string,
  replacements: KeyValueStringsObject[],
): string;

Replaces #{key} placeholders with values from a list of string records.

Usage

stringInterpolation("This string has #{dynamicData}", [
  { dynamicData: "a knot in it" },
]);
// "This string has a knot in it"

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

trim-whitespace: (value: string) => string

Trims outer whitespace and collapses repeated spaces into single spaces.

Usage

removeWhitespaceFromString("  This   has whitespace.  ");
// "This has whitespace."

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

Arr (Arrays)

Small array selection and deduplication helpers.

filter-array: (value: unknown[]) => unknown[]

Removes duplicate array items using strict equality. Object values are not deeply compared.

Usage

filterArray(["test", "test", "foo"]);
// ["test", "foo"]

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

head: (value: unknown[]) => unknown

Returns the first item in an array, or undefined for an empty array.

Usage

head(["first", "second"]);
// "first"

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

Obj (Objects)

Object checks and recursive merge helpers.

is-object

isArray(value: unknown): boolean;
isOfObjectType(value: unknown): boolean;
isObject(value: unknown): boolean;

Checks whether a value is an array, any non-null object-like value, or a non-array object.

Usage

isArray(["value"]); // true
isOfObjectType({ value: true }); // true
isObject(["value"]); // false
isObject({ value: true }); // true

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

merge-objects: (left: unknown, right: unknown) => unknown

Recursively merges objects and combines arrays while removing duplicate primitive values. Prototype-pollution keys are ignored during nested merges.

Usage

mergeObjects(
  { settings: { darkMode: false } },
  { settings: { compact: true } },
);
// { settings: { darkMode: false, compact: true } }

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

Fn (Functions)

Small composable function helpers.

compose: <T>(...fns: ((value: T) => T)[]) => (value: T) => T

Composes functions from right to left.

Usage

const add = (value: number) => value + 1;
const multiply = (value: number) => value * 2;

compose(add, multiply)(2);
// 5

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

curry

curry(fn: F.Function): (this: unknown, ...args: Parameters<typeof fn>) => any;

Returns a function that can receive a function's arguments over multiple calls.

Usage

const add = (a: number, b: number, c: number) => a + b + c;

curry(add)(1, 2)(3);
// 6

Install notes

# Copy src/index.ts into your project.
# Type dependency: ts-toolbelt.
# Keep ts-toolbelt for the current F.Function type import.

Cites

  • Source
  • Tests

pipe: <T>(...fns: ((value: T) => T)[]) => (value: T) => T

Composes functions from left to right.

Usage

const multiply = (value: number) => value * 2;
const add = (value: number) => value + 1;

pipe(multiply, add)(2);
// 5

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

repeat: (iterations: number) => <T>(fn: (value: T) => T) => (value: T) => T

Runs a callback a fixed number of times and returns the final value.

Usage

repeat(3)((value: number) => value + 1)(0);
// 3

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

Rx (Reactivity)

Timing and readiness helpers. wait-until-defined is deprecated for new code.

debounce: <T>(fn: (value?: T) => void, delay: number) => (value?: T) => void

Delays a callback until calls stop arriving during the delay window.

Usage

const save = debounce((value?: string) => {
  console.log(value);
}, 300);

save("latest value");

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

throttle: <T>(fn: (value?: T) => void, delay: number) => (value?: T) => null | number

Schedules the first callback in a delay window and ignores later calls while that timeout is active.

Usage

const report = throttle((value?: number) => {
  console.log(value);
}, 300);

report(1);
report(2);

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

wait-until-defined

wait(timeout: number): Promise<true>;
isDefined(check: () => boolean): Promise<boolean>;
checkDefinition(
  check: () => boolean,
  interval: number,
  attempts: number,
): Promise<boolean>;
waitUntilDefined(
  check: () => boolean,
  interval?: number,
  timeout?: number,
): Promise<boolean>;

Polls a callback until it returns true or the timeout expires. Deprecated: prefer the event or readiness signal that makes the value available.

Usage

await waitUntilDefined(() => ready, 100, 5000);

Install notes

# Deprecated: do not add this to new code.
# Dependencies: none.

Cites

  • Source
  • Tests

Obx (Observability)

Small helpers for observing values without changing the value flow.

trace: (label: string) => (value: unknown) => unknown

Logs a label and value, then returns the original value for use in a pipeline.

Usage

const result = trace("number")(2);
// logs: number: 2
// result: 2

Install notes

# Copy src/index.ts into your project.
# Dependencies: none.

Cites

  • Source
  • Tests

Doc (Documents)

Helpers for turning package metadata into Markdown.

update-markdown-list

logger(options: LoggerOptions): {
  debug(message: string, ...args: unknown[]): void;
  error(message: string, ...args: unknown[]): void;
};
processPackages(
  packagesDirectory: string,
  markdownFile: string,
  jsonFile: string,
  isLogging?: boolean,
): void;
getJsonData(
  packagePath: string,
  jsonFile: string,
  log: ReturnType<typeof logger>,
): string;
updateText(
  markdownFile: string,
  jsonFile: string,
  log: ReturnType<typeof logger>,
  packagesDirectory: string,
  packageName: string,
): void;
updateMd(
  markdownText: string,
  markdownFile: string,
  log: ReturnType<typeof logger>,
): void;

Reads package metadata and appends formatted package headings and descriptions to a Markdown file.

Usage

const log = logger({ file: "README.md" });

const description = getJsonData("./packages/example", "package.json", log);
updateMd(description, "./README.md", log);

Install notes

# Copy src/index.ts into your project.
# Uses Node.js built-ins only.

Cites

  • Source
  • Tests

Browse the full documentation for more examples.

License

MIT

About

Simple typed utilities generally written in a functional style for learning and utility 🧰

yowainwright.gitbook.io/common-utilities/

Topics

1locfunctionaljavascript-developmentlearninglodashramdajstypescripttypescript-libraryutilitiesutility-library

Resources

Readme
MIT license
Activity

Stars

29 stars

Watchers

1 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.