main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
846 bytes
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | var normalize = require('../../normalize')
|
---|
4 | var Schema = require('./schema')
|
---|
5 | var DefinedInfo = require('./defined-info')
|
---|
6 |
|
---|
7 | module.exports = create
|
---|
8 |
|
---|
9 | function create(definition) {
|
---|
10 | var space = definition.space
|
---|
11 | var mustUseProperty = definition.mustUseProperty || []
|
---|
12 | var attributes = definition.attributes || {}
|
---|
13 | var props = definition.properties
|
---|
14 | var transform = definition.transform
|
---|
15 | var property = {}
|
---|
16 | var normal = {}
|
---|
17 | var prop
|
---|
18 | var info
|
---|
19 |
|
---|
20 | for (prop in props) {
|
---|
21 | info = new DefinedInfo(
|
---|
22 | prop,
|
---|
23 | transform(attributes, prop),
|
---|
24 | props[prop],
|
---|
25 | space
|
---|
26 | )
|
---|
27 |
|
---|
28 | if (mustUseProperty.indexOf(prop) !== -1) {
|
---|
29 | info.mustUseProperty = true
|
---|
30 | }
|
---|
31 |
|
---|
32 | property[prop] = info
|
---|
33 |
|
---|
34 | normal[normalize(prop)] = prop
|
---|
35 | normal[normalize(info.attribute)] = prop
|
---|
36 | }
|
---|
37 |
|
---|
38 | return new Schema(property, normal, space)
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.