Skip to content

Instantly share code, notes, and snippets.

@mikeric
Last active August 29, 2015 14:05
Show Gist options
  • Save mikeric/654d3512e9010689fc03 to your computer and use it in GitHub Desktop.
Save mikeric/654d3512e9010689fc03 to your computer and use it in GitHub Desktop.
Module interface styles

A

// require
sightglass = require('sightglass')

// global usage
sightglass.root = '.'
sightglass(obj, 'user.address:city', function() {})

// scoped usage
sightglass2 = sightglass.extend({root: '.'})
sightglass2(obj, 'user.address:city', function() {})

B

// require
sightglass = require('sightglass')

// global usage
sightglass.root = '.'
sightglass.observe(obj, 'user.address:city', function() {})

// scoped usage
sightglass2 = sightglass({root: '.'})
sightglass2.observe(obj, 'user.address:city', function() {})

C

// require
sightglass = require('sightglass')

// global usage
sightglass.root = '.'
sightglass.observe(obj, 'user.address:city', function() {})

// scoped usage
sightglass2 = new sightglass({root: '.'})
sightglass2.observe(obj, 'user.address:city', function() {})

D

// require
Sightglass = require('sightglass')

// there is no global usage :(

// scoped usage
sightglass = new Sightglass({root: '.'})
sightglass(obj, 'user.address:city', function() {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment