Skip to content

cluesurf/kink.js








@cluesurf/kink

Standard Error Creation in TypeScript




Installation

pnpm add @cluesurf/kink
yarn add @cluesurf/kink
npm i @cluesurf/kink

Example

import Kink from '@cluesurf/kink'

const host = '@cluesurf/kink'

type Base = {
  syntax_error: {}
}

type Name = keyof Base

Kink.base(host, 'syntax_error', () => ({
  code: 1,
  note: 'Syntax error',
}))

Kink.code(host, (code: number) => code.toString(16).padStart(4, '0'))

export default function kink<N extends Name>(form: N, link?: Base[N]) {
  return new Kink(Kink.makeBase(host, form, link))
}
import kink from './example.js'

try {
  throw kink('syntax_error')
} catch (e) {
  console.log(e)
}

Tree

License

MIT

ClueSurf

Made by ClueSurf, meditating on the universe ¤. Follow the work on YouTube, X, Instagram, Substack, Facebook, and LinkedIn, and browse more of our open-source work here on GitHub.

About

Standard Error Creation in TypeScript

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published