Code Monkey home page Code Monkey logo

lace's Introduction

lace

Lace is a control flow library that doesn't get in your way. Here's how it works:

// Require the lib
var lace = require('lace');

// Call lace. Create a lacing (series of functions).
lace
(function(){
	// Within each of these functions are some helpers contained in the lace global.
	lace.next(); // This calls the next function in the series.
}) // Lace uses currying to create the lacing.
(function(){
	// Helpers are also available here.
	// All arguments are directly from the invocation of the previous lace.next (no appending or prepending of helper arguments).
	// The `this` context will be what lace.next was applied to.
	
	// Inner lacings are supported
	lace
	(function(){
		// Helpers will reference the inner lacing
		lace.next();
	})
	(function(){
		// Access to the outer lace helper is done through the lace.outer helper property
		lace.outer.next();
	});
})
(function(){
	// This was called from the lace.outer.next.
	// Everything should just work, without getting in your way.
});

Lace is all about asynchronous control flow. You can pass lace.next to asynchronous function such as setTimout, database query callbacks, etc.

Another thing to keep in mind, is that the first function is called asynchronously:

console.log('A');

lace
(function(){
	console.log('C');
})

console.log('B')

// Will output A B C

Terminology

Lace

Library name. Global exported object and helper.

Lacing

The lacing is the series of functions or function sets. A lacing function is one of the "steps" in the control flow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.