src/promissory-arbiter.js
function create () {
    /**
     * Arbiter has a few options to affect the way that subscribers are
     * notified and PublicationPromises are resolved.
     *
     * @typedef Options
     * @memberof Arbiter
     *
     * @property {boolean} persist=false When true, subscribers are notified
     *   of past messages.
     * @property {boolean} sync=false When true, invokes the subscription
     *   functions synchronously.
     * @property {boolean} preventBubble=false When true, only the topics
     *   that match the published topics exactly are invoked.
     * @property {number} latch=0.9999999999999999 When this number is less
     *   than one, it is the ratio of subscribers that must fulfilled before
     *   resolving the `PublicationPromise`. If greater or equal to one,
     *   then it is a count of the subscribers that must fulfill.
     * @property {boolean} settlementLatch=false Changes the resolving logic
     *   of `PublicationPromise` to be based off resolved rather than
     *   fulfilled promises. This means that failed subscribers will count
     *   toward the tally of latch.
     * @property {number} semaphor=Infinity The maximum number of subscribers
     *   to allowed to be pending at any given point in time.
     * @property {boolean} updateAfterSettlement=false If true, updates the
     *   `PublicationPromise` after it resolves.
     *
     * @example
     *
     * Arbiter.subscribe('a', log);
     * Arbiter.subscribe('a.b', log);
     * Arbiter.subscribe('a.b.c', log);
     * var promise = Arbiter.publish('a.b.c', {latch: 1});
     *
     * // Remeber publish is async by default?
     * // promise.pending === 3;
     * // promise.fulfilled === 0;
     * // promise.rejected === 0;
     */
    var
      topics = createNode(''),
      options = {
        persist: false,
        sync: false,
        preventBubble: false,
        latch: 0.9999999999999999,
        settlementLatch: false,
        semaphor: Infinity,
        updateAfterSettlement: false
      },
      arbiter = {
        _topics: topics,
        options: options,
        version: 'v1.0.0',
        id: mkGenerator(),
        create: create
      };

    arbiter.subscribe = partial1(subscribeDispatcher, arbiter);
    arbiter.publish = partial1(publish, arbiter);
    arbiter.unsubscribe = partial1(unsubscribe, arbiter);
    arbiter.resubscribe = partial1(resubscribe, arbiter);
    arbiter.removePersisted = partial1(removePersistedDispatcher, arbiter);

    return arbiter;
  }
function create () {
    /**
     * Arbiter has a few options to affect the way that subscribers are
     * notified and PublicationPromises are resolved.
     *
     * @typedef Options
     * @memberof Arbiter
     *
     * @property {boolean} persist=false When true, subscribers are notified
     *   of past messages.
     * @property {boolean} sync=false When true, invokes the subscription
     *   functions synchronously.
     * @property {boolean} preventBubble=false When true, only the topics
     *   that match the published topics exactly are invoked.
     * @property {number} latch=0.9999999999999999 When this number is less
     *   than one, it is the ratio of subscribers that must fulfilled before
     *   resolving the `PublicationPromise`. If greater or equal to one,
     *   then it is a count of the subscribers that must fulfill.
     * @property {boolean} settlementLatch=false Changes the resolving logic
     *   of `PublicationPromise` to be based off resolved rather than
     *   fulfilled promises. This means that failed subscribers will count
     *   toward the tally of latch.
     * @property {number} semaphor=Infinity The maximum number of subscribers
     *   to allowed to be pending at any given point in time.
     * @property {boolean} updateAfterSettlement=false If true, updates the
     *   `PublicationPromise` after it resolves.
     *
     * @example
     *
     * Arbiter.subscribe('a', log);
     * Arbiter.subscribe('a.b', log);
     * Arbiter.subscribe('a.b.c', log);
     * var promise = Arbiter.publish('a.b.c', {latch: 1});
     *
     * // Remeber publish is async by default?
     * // promise.pending === 3;
     * // promise.fulfilled === 0;
     * // promise.rejected === 0;
     */
    var
      topics = createNode(''),
      options = {
        persist: false,
        sync: false,
        preventBubble: false,
        latch: 0.9999999999999999,
        settlementLatch: false,
        semaphor: Infinity,
        updateAfterSettlement: false
      },
      arbiter = {
        _topics: topics,
        options: options,
        version: 'v1.0.0',
        id: mkGenerator(),
        create: create
      };

    arbiter.subscribe = partial1(subscribeDispatcher, arbiter);
    arbiter.publish = partial1(publish, arbiter);
    arbiter.unsubscribe = partial1(unsubscribe, arbiter);
    arbiter.resubscribe = partial1(resubscribe, arbiter);
    arbiter.removePersisted = partial1(removePersistedDispatcher, arbiter);

    return arbiter;
  }
function create ( ) { /**
     * Arbiter has a few options to affect the way that subscribers are
     * notified and PublicationPromises are resolved.
     *
     * @typedef Options
     * @memberof Arbiter
     *
     * @property {boolean} persist=false When true, subscribers are notified
     *   of past messages.
     * @property {boolean} sync=false When true, invokes the subscription
     *   functions synchronously.
     * @property {boolean} preventBubble=false When true, only the topics
     *   that match the published topics exactly are invoked.
     * @property {number} latch=0.9999999999999999 When this number is less
     *   than one, it is the ratio of subscribers that must fulfilled before
     *   resolving the `PublicationPromise`. If greater or equal to one,
     *   then it is a count of the subscribers that must fulfill.
     * @property {boolean} settlementLatch=false Changes the resolving logic
     *   of `PublicationPromise` to be based off resolved rather than
     *   fulfilled promises. This means that failed subscribers will count
     *   toward the tally of latch.
     * @property {number} semaphor=Infinity The maximum number of subscribers
     *   to allowed to be pending at any given point in time.
     * @property {boolean} updateAfterSettlement=false If true, updates the
     *   `PublicationPromise` after it resolves.
     *
     * @example
     *
     * Arbiter.subscribe('a', log);
     * Arbiter.subscribe('a.b', log);
     * Arbiter.subscribe('a.b.c', log);
     * var promise = Arbiter.publish('a.b.c', {latch: 1});
     *
     * // Remeber publish is async by default?
     * // promise.pending === 3;
     * // promise.fulfilled === 0;
     * // promise.rejected === 0;
     */ var topics = createNode ( '' ) , options = { persist : false , sync : false , preventBubble : false , latch : 0.9999999999999999 , settlementLatch : false , semaphor : Infinity , updateAfterSettlement : false } , arbiter = { _topics : topics , options : options , version : 'v1.0.0' , id : mkGenerator ( ) , create : create } ; arbiter . subscribe = partial1 ( subscribeDispatcher , arbiter ) ; arbiter . publish = partial1 ( publish , arbiter ) ; arbiter . unsubscribe = partial1 ( unsubscribe , arbiter ) ; arbiter . resubscribe = partial1 ( resubscribe , arbiter ) ; arbiter . removePersisted = partial1 ( removePersistedDispatcher , arbiter ) ; return arbiter ; }
Creates a new instance of Arbiter that is completely separate from the
original. It has its own set of topics, subscribers, and options.

@function create
@memberof Arbiter

@return {Arbiter} The new instance.

@example

var arbiter = Arbiter.create();
Arbiter.subscribe('a', function a () {});
arbiter.publish('a'); // Does not execute a
Creates a new instance of Arbiter that is completely separate from the original . It has its own set of topics subscribers and options .