Skip to content

A large collection of useful Typescript libraries for Deno

Notifications You must be signed in to change notification settings

brandonkal/deno-lib

Repository files navigation

Deno lib

A large collection of useful Typescript libraries for Deno. Each utility is provided in its own file at the root.

This monorepo also includes a few related npm modules to make working with Deno better.

Usage

Check the license information for the functionality you want. If permitted, import the functions you need.

import * as yamlTag from 'https://x.kite.run/lib/yaml-tag.ts'

This library used to be available at deno.land/x/lib. After the Deno team decided to break import URLs, the canonical import domain came into being.

Included Utilities

abort-iterator.ts

Creates an iterator that is abortable. Based on the npm package by the same name

archieml.js

Parse a string of text as ArchieML.

args.ts

Utilities for parsing CLI arguments.

debug.ts

Debugging utility for Deno. Ported from the npm package by the same name.

dedent.ts

Dedent is a tagged template literal function. It is used by yaml-tag.ts and has tests to ensure consistency with a whitespace-sensitive content.

doc-gen.ts

Parse File-level JSDoc from a folder of TS/JS files for document generation

drone.ts

TypeScript types for Drone CI configuration.

emittery.ts

Simple and modern async event emitter Ported from the node module@0.7.1

function.ts

Kite™️ Support for OpenFaaS Functions.

go.ts

Simplified async error handling in TypeScript.

hash-object.ts

Take a JavaScript object and compute a sha256 hash of it for comparison.

http-cache-semantics.ts

Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies. Ported from the npm package by the same name. Code optained via the BSD-2 license. See attribution below.

karabiner.ts

A library and DSL to generate karabiner.json config. Can result in a 30x line reduction.

  1. Call rule()
  2. Call out()

kite.ts

Kite™️ is a Simplified Config Generation Library Ground Rules:

  1. No async code. Ever.
  2. No console.log
  3. post-processors cannot generate new objects
  4. Everything is a function. Export it as default and optionally call make() if import.meta.main
  5. Contract: All module functions should be a function that accepts or ignores one object argument.
  6. make() should always be in scope for all config gen modules.

kubernetes.ts

Kubernetes Config Generation Library Refer to kite.ts for more info.

kx.ts

kx is a simplified Kubernetes Config SDK for Kite.

magic-string.js

Manipulate strings like a wizard NOTE: This is the ES bundle with the sourcemap-codec import corrected. Source is available at https://cdn.jsdelivr.net/npm/magic-string@0.25.6/dist/magic-string.es.js

md5-apache.ts

A port of npm/apache-md5 for use with htpasswd. Portions of this work were obtained via the MIT License. Copyright (c) Gevorg Harutyunyan.

merge.ts

Provides generic object merging functions. Useful for config generation. Portions of this work were obtained via the Apache 2.0 License. That original work is Copyright 2020, jk authors.

proxymise.ts

Chainable Promise Proxy utility. Proxymise allows for method and property chaining without need for intermediate then() or await for cleaner and simpler code. @see https://github.com/kozhevnikov/proxymise

quokka-shim.ts

A shim for test functions when running Deno code. Consider using @brandonkal/deno-quokka and babel-plugin-deno npm packages for a more robust debugging experience.

reload.ts

CLI to reload Deno files as required. Pass number of commits to have the files reloaded.

resolve-object.ts

Recursively resolve any promises in an object to form a resulting JSON structure.

resolve-promise-object.ts

Recursively resolve any promises in an object to form a resulting JSON structure.

retry.ts

Retry an async function for exponential backoff. With a retryFetch implementation.

runtypes.ts

A Deno port of the great RunTypes library. Use TypeScript in the runtime. Port introduces loose conversion. This means a check() call may modify if a property required. Primitives should be assigned to themselves. "false" | "true" > boolean "null" > null "42" > 42 See https://github.com/brandonkal/runtypes

shellbox.ts

Utilities to sandbox subprocess commands

sourcemap-codec.ts

Encode/decode sourcemap mappings

testutils.ts

Utilities for testing. Replicates expect from Jest.

to_aml.js

Converts JSON structure to ArchieML text string.

unraw.ts

Undo String.raw. Convert raw escape sequences to their respective characters.

utils.ts

A collection of useful small functions in one location.

yaml-formatter.ts

Parses YAML or JSON input and prints out YAML documents with a stable object sort. Ideal for converting JSON to YAML. Useful as a lightweight CLI or as a formatting function.

yaml-tag.ts

Write YAML within TypeScript programs for cleaner and more concise code. This module provides the following exports:

  • y (yaml text tagged template function)
  • printYaml (JS Object Array to YAML multi-document text)

Others

@brandonkal/deno-quokka

This npm module provides basic Quokka.js support for executing Deno files. This helps speed up development of Deno libraries such as yaml-tag.ts.

babel-plugin-deno

This npm module rewrites imports to use the cache directory.

It can be used in combination with @brandonkal/deno-quokka for an interactive REPL for some Deno-flavored TypeScript code.

npm/register.js

Debug a Deno program via Node.

Contributions Welcome

Contributions or requests for focused utilities are encouraged.

License

© 2020 Brandon Kalinowski (@brandonkal). All rights reserved.

Not all files are released under a permissive open source license (though many are). In particular, the modules in the kite directory do not carry an open-source license.

See individual file headers for license information. Files without headers are © Brandon Kalinowski (@brandonkal). All rights reserved.

If a file contains no specified license, no license has been provided.

Why

It's simple really. Each module in this repository could have been released in its own repository. In the npm world, that would mean a seperate package. Each of those would contain their own license. With Deno, files are modules. The file is the distributed content. There is no "minification" step. Therefore, it is smarter to specify license information inside the files. It would be silly to provide a blanket license over the entire repository contents as that would require that a single license would apply to all files.

This approach also makes automation of license compliance simpler. The rules above are simple. You can use doc-gen.ts or another JSDoc parser to scan the file's structured header block for all your imports.