Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

s-loc

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s-loc

A simple service locator

  • 1.1.0
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
2
Weekly downloads
 
Created
Source

s-loc

Description: Service locator with some functionality behond basic register/get

var locator = require('s-loc')();

var locator = require('./index')();
var obj = {
orig : function() {
console.log('THIS HAPPENED');
},
backup: function() {
    console.log('THIS RIGHT HERE')
},
third: function() {
    console.log('last one happened');
},
last: function() {
    console.log('real lastone');
}


};

locator.register('testGet',obj);
locator.register('func',obj.last);

var func = locator.get('func');

var testGet = locator.get('testGet');
var testSecond = locator.get('testGet',true);
var testThird = locator.get('testGet',true,'third');




func(); //LOGS 'real lastone'
testGet(); //LOGS 'THIS HAPPENED'
testSecond(); //LOGS 'THIS RIGHT HERE'
testThird(); //LOGS 'last one happened'

###locator.register (NAME, Anything)

This is used to register a var in the locator. Note registering objects expose some extra things.

###locator.get(NAME,OVERRIDE(optional,boolean),OVERRIDE_NAME(optional,string))

locator.get is used to get something back out of the registry.

IF NOT OBJECT: If you registered a non object you ONLY pass in name to this function. Everything else will error.

IF OBJECT:

just name passed in === Will return first property of object

name and override = true === Will return second property of object

name and overridename === Will return the property with override name

Keywords

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc