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

webidl

v0.0.7

Published

An implementation of WebIDL in ECMAScript.

Downloads

6

Readme

webidl.js

An implementation of WebIDL in ECMAScript.

Goals and Scope

The initial goal of this project is to implement a "prollyfill" code generator based on the WebIDL specification in ECMAScript (i.e., implement the WebIDL ECMAScript bindings).

For the first version, webidl.js will take as input well-formed Web IDL and generate JavaScript code that:

  1. Implements the given WebIDL in conformance to WebIDL's WebIDL ECMAScript bindings.
  2. can be eval'ed immediately to implement a noop object.
  3. can be used indepedently of webidl.js.

The generated code will not depend on any external libraries.

#Proposed Architecture (in WebIDL) WebIDLCompiler will be based on Robin Berjon's WebIDL Parser,

interface WebIDLCompiler : WebIDL{
    static DOMString compile(DOMString dataFragment);
    static DOMString compile(object dataTree);
}

interface WebIDL{
    static object parse(); 
}

Where WebIDL is and instance of https://github.com/darobin/webidl2.js

##Examples of what we want to do (The following examples are hypothetical, as we don't actually have any running code yet! :) )

Given some WebIDL, like:

interface Vehicle {
    attribute DOMString make;
    attribute DOMString model;
    void move();
}

[Constructor, Constructor(DOMString make, optional DOMString model)]
interface Car : Vehicle {
     const octet maxspeed = 200;
     void drive([Clamp] octet speed);
};

webidl.js will implement the following in the browser:


var webIDL = new WebIDLCompiler();

//convert to javascript
var script = webIDL.compile(carIDLString);
eval(script); // noop methods by default

// interfaces are added to the global scope
console.log(window.Car);
console.log(window.Vehicle);
console.log(window.Car.prototype.drive);
console.log(Car.maxspeed === 200); 

// instances are valid and inheritance works properly
var car = new Car(); 
console.log(car instanceof window.Car === true); 
console.log(car instanceof window.Vehicle === true); 
console.log("make" in car === true); 
console.log("move" in car === true); 

// methods can be called on instances
car.drive();
window.Car.prototype.drive.call(car)

// methods can't be called on other objects (throws a type error)
try{ 
    window.Car.prototype.drive.call({}); 
}catch(e){
  console.log(e);
} 

// type checking is built-in (throws a type error)
try{ 
  car.drive({});
}catch(e){
  console.log(e);
} 

// type conversion is also buit-in
car.drive("100"); 

Contributing

We welcome code contributions in the form of pull requests. All pull requests are reviewed prior to being integrated.

To retain a high level of quality, we require that all contributed code include:

  • appropriate unit tests,
  • documentation,
  • and the code has been linted.

Linting, beautificaiton, and generation of documentation is handled by grunt..

Coding conventions

We attempt to adhere to the Google JavaScript Style Guide.

We are also moving to us JSDoc to document out code.

Before submitting code, please be sure to run grunt.

License

Copyright © 2013 Extensible Web Community Group

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.