Internal
A curated set of high-quality, well-tested, minimal browser modules.
Each module has high test-coverage and is tested against Chrome, Firefox and Webkit.
Install
Usage
A few examples below but see the src/ directory for the list of modules and the tests for usage.
maybe
Handle errors more gracefully.
import maybe from "internal/maybe"
const res = await maybe ( fetch ( "http://mat.tm" ))
if (res instanceof Error ) {
console. error (res)
return
}
const text = await res. text () copy
typeof
Gets the typeof a value at runtime.
import typeOf from "internal/typeof"
typeOf ( "hello" ) // "string"
typeOf ( /asdf/ ) // "regexp" copy
deferred
A promise you can pass around.
import Deferred from "internal/deferred"
const deferred = new Deferred ()
doSomething (deferred)
const res = await deferred
function doSomething (deferred) {
setTimeout (() => {
deferred. resolve ( "ok" )
}, 1000 )
} copy
ensure-error
Ensures that whatever comes back is an Error.
import ensureError from "internal/ensure-error"
const err = ensureError ( "oh no" )
err instanceof Error // true copy
Development
git clone https://github.com/matthewmueller/internal
# Install node_modules and browser drivers
make install
# Run the test suite
make test
# Build to dist/
make build copy
License
MIT