1.0.0 • Published 10 years ago

namespace-diff v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

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.

1.0.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago