Skip to content
Generate the diff between two namespaces.
JavaScript HTML
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
src
test
.gitignore
.jshintrc
.travis.yml
LICENSE
README.md
bower.json
gulpfile.js
package.json

README.md

namespace-diff.js

Travis build status Code Climate Test Coverage Dependency Status devDependency Status

Generate the diff between two namespaces.

About

A namespace is a series of strings broken up by a separator. For instance, books.book.comments and books.about use a period as a separator. This library can generate the difference between two namespaces in terms of outgoing parts and incoming parts.

For instance, given the above namespaces, this library would return:

{
  outStates: ['books.book.comments', 'books.book'],
  inStates: ['books.about']
}

API

namespaceDiff(start, end, separator = '.')

Generates the difference of start and end. Returns an object with two keys, outStates and inStates.

Optionally pass a separator to handle namespaces formatted differently. E.g.; this/namespace/uses/slashes. The separator defaults to a period.

The outbound array is reversed such that the deepest nested part is first in the array.

Undefined values

Attempting to enter an undefined state is a no-op; the outStates and inStates will be an empty array.

Leaving an undefined state and moving into a new state will include entering the root state, ''. This is the only time that the root state will be entered.

Something went wrong with that request. Please try again.