Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Latest commit

 

History

History
42 lines (36 loc) · 727 Bytes

PATTERNS.md

File metadata and controls

42 lines (36 loc) · 727 Bytes

Perfectly normal module

this module will only run once (and its result will be cached as if it was a normal require)

// m.js
module.exports = function (a, b, c) {
	return {
		some: function () {},
		api: '1'
	}	
}

so later you can do:

module.exports = function(m) {
	
}

or even

var m = require('./lib/m.js')

Perfectly normal async module

module.exports = function (a, b, c, callback) {
	callback(null, {
		some: function () {},
		api: '1'
	})
}

Pitfall module

this module will never be cached and will be run every time it is injected somewhere since it doesn't return anything (this sucks and I might change that in the future)

module.exports = function (a, b, c) {
	
}