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

emscripten-library-decorator

v0.2.2

Published

Decorators for writing Emscripten libraries

Downloads

430

Readme

emscripten-library-decorator

This package provides decorators for writing Emscripten libraries.

function _print(message: string) {
	console.log(message);
}

@exportLibrary
class test {
	@dep(_print)
	static hello() {
		_print('Hello, World!!');
	}

	static foobar = 42;
};

The class decorator @exportLibrary exports the static members of the class as an Emscripten library. Place it with no arguments just before the class.

The property decorator @dep is for listing dependencies. It ensures that when an exported function is used in the C or C++ code, other required functions are also included in the compiled Emscripten output after dead code elimination. Place it just before a function with any number of parameters listing the other required functions.

The dependencies should be global functions and their name should begin with an underscore. Otherwise Emscripten's name mangling will change their name in the output making any calls to them fail.

There is a longer article with more information.

API

Docs generated using docts

Function defineHidden

@_defineHidden decorator.
Assign to a local variable called _defineHidden before using.
Apply to a property to protect it from modifications and hide it.
Source code: <>

defineHidden( ) (target: Object, key: string) => void <>
 ▫ value? any

Function dep

@dep decorator.
Apply to a function, to list other required variables needing protection
from dead code removal.
Arguments can be functions or names of global variables.
Source code: <>

dep( ) (target: Object, functionName: string) => void <>
 ▪ depList ((...args: any[]) => any | string)[]

Function exportLibrary

@exportLibrary decorator.
Apply to a class with static methods, to export them as functions.
Source code: <>

exportLibrary( ) void <>
 ▪ target any

Function prepareNamespace

@prepareNamespace decorator.
Apply to an empty, named dummy class defined at the end of the namespace
block, to prepare its contents for export in an Emscripten library.
Namespaces with matching names in different files are merged together.
All code in the block is separated because Emscripten only outputs global
functions, not methods.
Source code: <>

prepareNamespace( ) (target: any) => void <>
 ▪ name string

Function publishNamespace

Call once per namespace at the global level, after all files with contents
in that namespace have been imported. Clears the namespace and exports a
"postset" function to populate it using its original code.
Source code: <>

publishNamespace( ) void <>
 ▪ name string

Function setEvil

Allow decorators to call eval() in the context that called them.
This is needed for various transformations.
Source code: <>

setEvil( ) void <>
 ▪ otherEval (code: string) => any must be this function: (code: string) => eval(code)

License

The MIT License

Copyright (c) 2015-2017 BusFaster Ltd