@termsurf/kink
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published







@termsurf/kink

Standard Error Creation in TypeScript




Installation

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

Example

import Kink from '@termsurf/kink'

const host = '@termsurf/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)
}

License

MIT

TermSurf

This is being developed by the folks at TermSurf, a California-based project for helping humanity master information and computation. Find us on Twitter, LinkedIn, and Facebook. Check out our other GitHub projects as well!

Readme

Keywords

none

Package Sidebar

Install

npm i @termsurf/kink

Weekly Downloads

288

Version

0.2.3

License

MIT

Unpacked Size

13.2 kB

Total Files

5

Last publish

Collaborators

  • lancejpollard