![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Low-level type-centric utility functions for Javascript.
Typedef can be used on the server with NodeJS or on the client, built with Browserify, so install with npm:
npm install typedef
Child
, Base
)While traditionally, favoring composition over inheritance in Javascript is typically the way to go, classic inheritance can be useful if used sparingly.
This is the extends
function that is used in Typescript, Coffeescript, ES6
compilers, etc. It uses prototypes to setup something similar to to classical
single inheritance.
var extends_ = require('typedef').extends;
function Base()
{
console.log('base ctor');
}
Base.prototype.method = function()
{
console.log('hello from base class');
}
...
extends_(Child, Base);
function Child()
{
// Call base constructor
Child.Super.apply(this, arguments);
console.log('child ctor');
}
Child.prototype.method2 = function()
{
console.log('hello from child class');
}
...
var foo = new Child();
// base ctor
// child ctor
foo.method();
// hello from base class
foo.method2();
// hello from child class
foo instanceof Child;
// true
foo instanceof Base;
// true
Constructor
, Mixin
)Class composition method. Mixin methods into Constructor.prototype
.
If Mixin
is a constructor function (class), then mixin all static properties
into Constructor
, and everything on Mixin.prototype
to
Constructor.prototype
. If Mixin
is just a Plain Old Object, then simply add
the members of Mixin
to Contructor.prototype
.
f
) and getName(f
)Get the name of all the parameters or name for function f
.
var getArguments = require('typedef').getArguments;
var getName = require('typedef').getName;
function foo(a, b, c)
{
...
}
getArguments(foo);
// ['a', 'b', 'c']
getName(foo);
// 'foo'
The library files are all decorated with JSDoc3-style
annotations that work great with the Tern code inference
system. Combined with the Node plugin (see this project's .tern-project
file), you can have intelligent autocomplete for methods in this library.
Testing is done with Tape and can be run
with the command npm test
.
Automated CI cross-browser testing is provided by Testling.
Copyright 2014 Brandon Valosek
Typedef is released under the MIT license.
FAQs
Low-level type-centric utility functions for Javascript.
The npm package typedef receives a total of 163 weekly downloads. As such, typedef popularity was classified as not popular.
We found that typedef demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.