Package Exports
- custom-factory
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (custom-factory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
CustomFactory

easily add the factory ability to your class which can singleton, name, register/unregister and aliases your object items.
- CustomFactory
register(aClass)
: (class method) register the aClass to the CustomFactoryunregister(aName)
: (class method) unregister the aName from the CustomFactoryalias/aliases(aClass, aliases...)
: (class method) create aliases to the aClass.constructor(aName)
: get a singleton instance from the CustomFactoryCustomFactory[aName]
: get the registered class from the CustomFactory.
Usage
developer:
factory = require 'custom-factory'
class Codec
factory Codec
constructor: -> return super
initialize: (aOptions)->
@bufferSize = aOptions.bufSize if aOptions
encode:->
register = Codec.register
aliases = Codec.aliases
class TextCodec
register TextCodec
aliases TextCodec, 'utf8', 'utf-8'
constructor: Codec
encode:->
class JsonCodec
register JsonCodec, TextCodec
constructor: -> return super
encode:->
user
# get the JsonCodec Class
# lowercase name only here:
TextCodec = Codec['text']
JsonCodec = Codec['json']
# or
JsonCodec = TextCodec['json']
# get the global JsonCodec instance from the Codec
json = Codec('json')
# or:
json = JsonCodec()
text = Codec('text') # or Codec('utf8')
JsonCodec().should.be.equal Codec('json')
# create a new JsonCodec instance.
json2 = new JsonCodec()
json2.should.not.be.equal json