@128technology/yinz
Advanced tools
Comparing version 5.0.0-alpha.1 to 5.0.0-alpha.2
@@ -31,2 +31,11 @@ "use strict"; | ||
}); | ||
it('should be able to delete', () => { | ||
const instance = new __1.LeafListInstance(leafListModel, mockConfigXML, {}); | ||
const newItemXML = xmlUtil_1.default.toElement(` | ||
<test:vector xmlns:test="http://foo.bar">bar</test:vector> | ||
`); | ||
instance.add(newItemXML); | ||
instance.delete(util_1.allow, 'foo'); | ||
chai_1.expect(instance.toJSON(util_1.allow).vector).to.deep.equal(['bar']); | ||
}); | ||
it('should serialize to JSON', () => { | ||
@@ -33,0 +42,0 @@ const instance = new __1.LeafListInstance(leafListModel, mockConfigXML, {}); |
@@ -20,2 +20,3 @@ import { Element } from 'libxmljs'; | ||
add(config: Element | LeafJSON): void; | ||
delete(authorized: Authorized, value: string): void; | ||
toJSON(authorized: Authorized, camelCase?: boolean, convert?: boolean): { | ||
@@ -22,0 +23,0 @@ [name: string]: LeafListJSONValue; |
@@ -38,2 +38,8 @@ "use strict"; | ||
} | ||
delete(authorized, value) { | ||
if (!authorized(this)) { | ||
throw new Error('Unauthorized'); | ||
} | ||
this.children = this.children.filter(leafListItem => leafListItem.getRawValue(authorized) !== value); | ||
} | ||
toJSON(authorized, camelCase = false, convert = true) { | ||
@@ -40,0 +46,0 @@ if (!authorized(this)) { |
{ | ||
"name": "@128technology/yinz", | ||
"version": "5.0.0-alpha.1", | ||
"version": "5.0.0-alpha.2", | ||
"description": "A module for injesting a YIN datamodel and handling instance data.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
638028
8659