package
A curated set of high-quality, well-tested browser modules
npm install internalGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
33.5 kB
Includes dependencies.
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.
npm install internalA few examples below but see the src/ directory for the list of modules and the tests for usage.
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()Gets the typeof a value at runtime.
import typeOf from "internal/typeof"
typeOf("hello") // "string"
typeOf(/asdf/) // "regexp"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)
}Ensures that whatever comes back is an Error.
import ensureError from "internal/ensure-error"
const err = ensureError("oh no")
err instanceof Error // truegit clone https://github.com/matthewmueller/internal
# Install node_modules and browser drivers
make install
# Run the test suite
make test
# Build to dist/
make buildMIT