Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(package): export interface namespaces in addition to merged methods #36

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ Determine if a JsonML node has attributes

### XML

```js
const { xml } = require('@condenast/jsonml.js');
```

#### `fromXML( elem, filter )`

Converts XML nodes to JsonML
Expand Down
19 changes: 17 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
'use strict';

const utils = require('./utils');
const dom = require('./dom');
const html = require('./html');
const utils = require('./utils');
const xml = require('./xml');
Object.assign(module.exports, utils, dom, html, xml);

const namespaces = {
dom,
html,
utils,
xml,
};

// Export all methods and namespaced interfaces
Object.assign(module.exports,
namespaces,
dom,
html,
utils,
xml
);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current babel configuration doesn't allow for namespaces, ...namespaces just yet

16 changes: 14 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ const xml = require('../lib/xml');
const utils = require('../lib/utils');

describe('JsonML module index', function() {
it('should merge and export interfaces', function() {
assert.deepEqual(JsonML, Object.assign({}, dom, html, xml, utils));
it('should export the dom namespace', function() {
assert.deepEqual(JsonML.dom, dom);
});

it('should export the html namespace', function() {
assert.deepEqual(JsonML.html, html);
});

it('should export the xml namespace', function() {
assert.deepEqual(JsonML.xml, xml);
});

it('should export the utils namespace', function() {
assert.deepEqual(JsonML.utils, utils);
});

it('should export all methods from the dom interface', function() {
Expand Down