Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including core-lang with all npm packages installed. Try it out:

var coreLang = require("core-lang")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

core-lang v1.1.1

Classes that should be in the core of the JavaScript language. Collections. Promises. Reflection. Working and tested from IE8+.


Classes that should be in the JavaScript language itself. The collections have a rich API to work with the data, full promises support, well written documentation and TypeScript definitions.


Available classes:


All collections inherit from XIterable. It returns an iterator and offers the classic Array methods of iteration, also filter, map/reduce, etc. with the same signature.

In addition some methods are added (some of them inspired from groovy) to make chaining more easier (such as groupBy, transform, first or butFirst).

Last but not least the collections have full Promises support, and allow processing of their content using the Promise API. For example, assuming that our collection contains promises, we can:

    .map(Promise.resolve, Promise) // make them promises
    .mapPromise(function(it) {
        // mapPromise first resolves the items in the collection,
        // then it applies the mapping function
        // all the items are resolved at his stage, so we have the initial
        // array, being iterated over. We create new promises.
        return Promise.resolve(it * it);
    }).then(function(collection) {
        // not only the value before mapping gets resolved, but also
        // the result gets first Promise.resolved and only after
        // added back into the collection
        assert.equal([1,4,9,16], collection.asArray());

Furthermore since the collections are written in TypeScript, the module embeds the .d.ts file, so you get full autocomplete and documentation support from the IDE (pictured Visual Studio Code)



formatis a very simple string formatting method that uses positional parameters in the spirit of .NET:

var format = require("core-lang/lib/stringUtils").format;

var text = format("{0} {1}!", "Hello", "World");

console.log(text); // will output 'Hello World!'


reflect, as its name implies, offers some utility methods that allow reflection operations on objects and functions.

Here is a sample of reflect displaying its own API:

var reflect = require("core-lang/lib/reflect"),
    format = require("core-lang/lib/stringUtils").format;

// reflect displaying its own API
reflect.functions(reflect).forEach(function(method) {
    console.log(format("function {0}({1});",
            .join(", ")

This will output:

function functionName(f);
function functions(obj);
function argumentNames(f);
function create(clazz, args);
function invoke(f, args);


  • v1.1.1 2015-09-15 Collections have the types correctly exported, and the Promise is the ES6 implementation.
  • v1.1.0 2015-09-10 Exported the reflect methods, and string format.
  • v1.0.1 2015-09-05 Added a bunch of mocha tests. (unit test)
  • v1.0.0 2015-08-31 Initial release.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free