Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebIDL helpers for JavaScript

πŸ“š WebIDL infrastructure for making JavaScript ↔️ JavaScript bindings

Installation

npm install @webfill/webidl

Usage

import { bindInterface, defineOperation, types } from "@webfill/webidl";

class Dog {
  bark() {
    console.log("woof");
  }
  eat(food) {
    console.log(`eating ${food}`);
  }
}
Dog = bindInterface(Dog, "Dog");
defineOperation(Dog.prototype, "bark", [], types.undefined)
defineOperation(Dog.prototype, "eat", [types.DOMString], types.undefined);

const dog = new Dog();
//=> Uncaught TypeError: Illegal constructor

const dog = Object.create(Dog.prototype);
dog.bark();
//=> 'woof'

dog.eat();
//=> Uncaught TypeError: Failed to execute 'eat' on 'Dog': 1 argument required, but only 0 present.

dog.eat("πŸ₯©");
//=> 'eating πŸ₯©'

About

πŸ“š WebIDL infrastructure for making JavaScript ↔️ JavaScript bindings

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages