npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

runtime-typesafety

v3.0.2

Published

an utility to propose a way to implement type-safety at run-time, not compile-time

Downloads

2

Readme

runtime-typesafety

Synopsys

function typesafe_function({
  fn                  , // Your function to protect.
  typesafe_input      , // The validator for the input parameters.
  typesafe_output     , // The validator for the output parameters.
  tags                , // Tags you wish to set; see below.
  property            , // The property descriptor to set on the protected func.
  on_enter            , // The callback to be called when `fn` is called.
  on_leave            , // The callback to be called when `fn` exitted.
  on_leave_with_error , // The callback to be called when `fn` exitted with an error.
  on_input_error      , // The callback to be called when the input validation failed.
  on_output_error     , // The callback to be called when the ouput validation failed.
  unprotected_input   , // If true, `preventUndefined()` is not applied to input arguments.
  unprotected_output  , // If true, `preventUndefined()` is not applied to output arguments.
}) {
}

typesafe_function() protects your functions from undefined values at runtime and offers information to diagnosis where these extraterrestrial undefined values come from.

See prevent-undefined for further information about preventUndefined() function which is a roubust system to protect your code from accidentally accessing undefined values via incorrect field names.

Note that the named arguments are processed by fold-args so that an earlier argument will be overridden by the latter arguments; for further information, see fold-args.

Callbacks

There are currently five callback functions which enable processes outside the protected function to receive various events which runtime-typesafe notifies.

  • on_enter
  • on_leave
  • on_leave_with_error
  • on_input_error
  • on_output_error
function on_callback( named_arguments : t_callback_arguments );

t_callback_arguments : object(
  fn              : function(), // the protected function
  fn_name         : string(),   // the name of the original function
  typesafe_input  : function(), // the input validator
  typesafe_output : function(), // the output validator
);

t_callback_arguments_on_enter : and(
  t_callback_arguments(),
  object(
    args : array_of( any() ), // the arguments which are passed when
                              // the protected function is called.
  ),
);

t_callback_arguments_on_leave : and(
  t_callback_arguments(),
  object(
    result : any(), // the result value when the protected function exits
                    // from a calling session.
  ),
);

History

v1.0.0

(Tue, 10 Jan 2023 13:35:00 +0900) Released.

v1.0.1

(Tue, 10 Jan 2023 14:17:43 +0900) Updated README.md and the description in package.js.

v1.0.2

(Wed, 11 Jan 2023 10:50:48 +0900) Updated README.md to correct a grammatical error.

v1.0.3

(Fri, 20 Jan 2023 16:06:02 +0900) added set_typesafe_tags() function.

v3.0.0

(Tue, 21 Feb 2023 17:21:30 +0900) Updated the major version to 3; version 3 depends on [email protected] or later and [email protected] or later.

v3.0.1

(Mon, 08 May 2023 13:44:27 +0900) Though, actual modification was done on May 2 2023. Send trace_validator_result via callback_handler on any error occured while execution.

v3.0.2

(Mon, 08 May 2023 19:04:28 +0900) Set SchemaValidatorContext from vanilla-schema-validator to Error objects.

Conclusion

Thank you very much for your attention.

Atsushi Oka / I'm from Tokyo. For further information, see my github account.

Github Repository of runtime-typesafety