Socket
Socket
Sign inDemoInstall

typed-javascript

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    typed-javascript

a simple dynamic type checking module in JavaScript


Version published
Weekly downloads
0
Maintainers
1
Install size
21.8 kB
Created
Weekly downloads
 

Readme

Source

typed-javascript

Simple dynamic type checking for JavaScript. Runs in Node.js and in browser, and can be set off for production.

Include in Node.js:

var T = require("./typed");

Include in browser

<script src="typed.js"></script>

See example.js for additional examples and typed.js for the source.

// Define two simple types
T.define("Person", {
    name: null,
    age: null
});

T.define("Country", {
    name: null
});

// Test type using in a normal JavaScript function
var test = function (person) {
    // Ensure type
    person = T.Person(person);

    console.log(person.name + " is " + person.age + " years old.");
};

// Test types automatically
var test2 = T.fn(T.Person, T.Country, function(person, country) {
    console.log(person.name + " is from " + country.name + ".");
});

test({ name : "foo", age : 20});
test2({ name : "bar", age : 30}, { name : "Internet" });

Keywords

FAQs

Last updated on 26 Jan 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc