https://github.com/jamesplease/namespace-diff.js
Generate the diff between two namespaces.
https://github.com/jamesplease/namespace-diff.js
Last synced: 3 months ago
JSON representation
Generate the diff between two namespaces.
- Host: GitHub
- URL: https://github.com/jamesplease/namespace-diff.js
- Owner: jamesplease
- License: mit
- Created: 2015-02-07T17:06:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-09T20:31:26.000Z (about 10 years ago)
- Last Synced: 2025-03-12T13:11:27.435Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 266 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# namespace-diff.js
[](https://travis-ci.org/jmeas/namespace-diff.js)
[](https://codeclimate.com/github/jmeas/namespace-diff.js)
[](https://codeclimate.com/github/jmeas/namespace-diff.js)
[](https://david-dm.org/jmeas/namespace-diff.js)
[](https://david-dm.org/jmeas/namespace-diff.js#info=devDependencies)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:
```js
{
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.