Socket
Socket
Sign inDemoInstall

moddle

Package Overview
Dependencies
1
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.6.2

13

Gruntfile.js

@@ -55,13 +55,4 @@ 'use strict';

}
},
}
jsdoc: {
dist: {
src: [ '<%= config.sources %>/**/*.js' ],
options: {
destination: 'docs/api',
plugins: [ 'plugins/markdown' ]
}
}
}
});

@@ -74,3 +65,3 @@

grunt.registerTask('default', [ 'jshint', 'test', 'jsdoc' ]);
grunt.registerTask('default', [ 'jshint', 'test' ]);
};

5

lib/descriptor-builder.js

@@ -153,3 +153,3 @@ 'use strict';

DescriptorBuilder.prototype.addTrait = function(t) {
DescriptorBuilder.prototype.addTrait = function(t, inherited) {

@@ -166,3 +166,4 @@ var allTypes = this.allTypes;

p = assign({}, p, {
name: p.ns.localName
name: p.ns.localName,
inherited: inherited
});

@@ -169,0 +170,0 @@

@@ -111,5 +111,11 @@ 'use strict';

/**
* Traverse the type hierarchy from bottom to top.
* Traverse the type hierarchy from bottom to top,
* calling iterator with (type, inherited) for all elements in
* the inheritance chain.
*
* @param {Object} nsName
* @param {Function} iterator
* @param {Boolean} [trait=false]
*/
Registry.prototype.mapTypes = function(nsName, iterator) {
Registry.prototype.mapTypes = function(nsName, iterator, trait) {

@@ -121,9 +127,19 @@ var type = isBuiltInType(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];

/**
* Traverse the selected trait.
*
* @param {String} cls
*/
function traverseTrait(cls) {
return traverseSuper(cls, true);
}
/**
* Traverse the selected super type or trait
*
* @param {String} cls
* @param {Boolean} [trait=false]
*/
function traverseSuper(cls) {
function traverseSuper(cls, trait) {
var parentNs = parseNameNs(cls, isBuiltInType(cls) ? '' : nsName.prefix);
self.mapTypes(parentNs, iterator);
self.mapTypes(parentNs, iterator, trait);
}

@@ -135,7 +151,8 @@

forEach(type.superClass, traverseSuper);
forEach(type.superClass, trait ? traverseTrait : traverseSuper);
iterator(type);
// call iterator with (type, inherited=!trait)
iterator(type, !trait);
forEach(type.traits, traverseSuper);
forEach(type.traits, traverseTrait);
};

@@ -157,4 +174,4 @@

this.mapTypes(nsName, function(type) {
builder.addTrait(type);
this.mapTypes(nsName, function(type, inherited) {
builder.addTrait(type, inherited);
});

@@ -161,0 +178,0 @@

{
"name": "moddle",
"version": "0.6.1",
"version": "0.6.2",
"description": "A library for importing meta-model based file formats into JS",

@@ -40,3 +40,2 @@ "directories": {

"grunt-contrib-watch": "~0.5.0",
"grunt-jsdoc": "~0.5.1",
"grunt-mocha-test": "^0.12.4",

@@ -43,0 +42,0 @@ "grunt-release": "^0.7.0",

@@ -8,2 +8,3 @@ {

"name": "CustomRoot",
"superClass": [ "Base" ],
"extends": [ "b:Root" ],

@@ -16,2 +17,8 @@ "properties": [

{
"name": "Base",
"properties": [
{ "name": "customBaseAttr", "type": "Integer", "isAttr": true }
]
},
{
"name": "CustomGeneric",

@@ -18,0 +25,0 @@ "superClass": [ "Element" ],

@@ -16,2 +16,24 @@ 'use strict';

describe('descriptor', function() {
it('should indicate non-inherited', function() {
// given
var ComplexType = model.getType('b:Root');
// when
var descriptor = model.getElementDescriptor(ComplexType),
customAttrDescriptor = descriptor.propertiesByName['customAttr'],
customBaseAttrDescriptor = descriptor.propertiesByName['customBaseAttr'],
ownAttrDescriptor = descriptor.propertiesByName['ownAttr'];
// then
expect(customAttrDescriptor.inherited).to.be.false;
expect(customBaseAttrDescriptor.inherited).to.be.false;
expect(ownAttrDescriptor.inherited).to.be.true;
});
});
it('should plug-in into type hierarchy', function() {

@@ -18,0 +40,0 @@

@@ -66,3 +66,9 @@ 'use strict';

var expectedDescriptorProperties = [
{ name: 'id', type: 'String', isAttr: true, ns: { name: 'props:id', prefix: 'props', localName: 'id' } }
{
name: 'id',
type: 'String',
isAttr: true,
ns: { name: 'props:id', prefix: 'props', localName: 'id' },
inherited: true
}
];

@@ -72,4 +78,16 @@

'id': { name: 'id', type: 'String', isAttr: true, ns: { name: 'props:id', prefix: 'props', localName: 'id' } },
'props:id': { name: 'id', type: 'String', isAttr: true, ns: { name: 'props:id', prefix: 'props', localName: 'id' } }
'id': {
name: 'id',
type: 'String',
isAttr: true,
ns: { name: 'props:id', prefix: 'props', localName: 'id' },
inherited: true
},
'props:id': {
name: 'id',
type: 'String',
isAttr: true,
ns: { name: 'props:id', prefix: 'props', localName: 'id' },
inherited: true
}
};

@@ -76,0 +94,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc