This commit is contained in:
9
node_modules/property-information/lib/util/case-insensitive-transform.js
generated
vendored
Normal file
9
node_modules/property-information/lib/util/case-insensitive-transform.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
var caseSensitiveTransform = require('./case-sensitive-transform')
|
||||
|
||||
module.exports = caseInsensitiveTransform
|
||||
|
||||
function caseInsensitiveTransform(attributes, property) {
|
||||
return caseSensitiveTransform(attributes, property.toLowerCase())
|
||||
}
|
||||
7
node_modules/property-information/lib/util/case-sensitive-transform.js
generated
vendored
Normal file
7
node_modules/property-information/lib/util/case-sensitive-transform.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = caseSensitiveTransform
|
||||
|
||||
function caseSensitiveTransform(attributes, attribute) {
|
||||
return attribute in attributes ? attributes[attribute] : attribute
|
||||
}
|
||||
39
node_modules/property-information/lib/util/create.js
generated
vendored
Normal file
39
node_modules/property-information/lib/util/create.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict'
|
||||
|
||||
var normalize = require('../../normalize')
|
||||
var Schema = require('./schema')
|
||||
var DefinedInfo = require('./defined-info')
|
||||
|
||||
module.exports = create
|
||||
|
||||
function create(definition) {
|
||||
var space = definition.space
|
||||
var mustUseProperty = definition.mustUseProperty || []
|
||||
var attributes = definition.attributes || {}
|
||||
var props = definition.properties
|
||||
var transform = definition.transform
|
||||
var property = {}
|
||||
var normal = {}
|
||||
var prop
|
||||
var info
|
||||
|
||||
for (prop in props) {
|
||||
info = new DefinedInfo(
|
||||
prop,
|
||||
transform(attributes, prop),
|
||||
props[prop],
|
||||
space
|
||||
)
|
||||
|
||||
if (mustUseProperty.indexOf(prop) !== -1) {
|
||||
info.mustUseProperty = true
|
||||
}
|
||||
|
||||
property[prop] = info
|
||||
|
||||
normal[normalize(prop)] = prop
|
||||
normal[normalize(info.attribute)] = prop
|
||||
}
|
||||
|
||||
return new Schema(property, normal, space)
|
||||
}
|
||||
40
node_modules/property-information/lib/util/defined-info.js
generated
vendored
Normal file
40
node_modules/property-information/lib/util/defined-info.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict'
|
||||
|
||||
var Info = require('./info')
|
||||
var types = require('./types')
|
||||
|
||||
module.exports = DefinedInfo
|
||||
|
||||
DefinedInfo.prototype = new Info()
|
||||
DefinedInfo.prototype.defined = true
|
||||
|
||||
var checks = [
|
||||
'boolean',
|
||||
'booleanish',
|
||||
'overloadedBoolean',
|
||||
'number',
|
||||
'commaSeparated',
|
||||
'spaceSeparated',
|
||||
'commaOrSpaceSeparated'
|
||||
]
|
||||
var checksLength = checks.length
|
||||
|
||||
function DefinedInfo(property, attribute, mask, space) {
|
||||
var index = -1
|
||||
var check
|
||||
|
||||
mark(this, 'space', space)
|
||||
|
||||
Info.call(this, property, attribute)
|
||||
|
||||
while (++index < checksLength) {
|
||||
check = checks[index]
|
||||
mark(this, check, (mask & types[check]) === types[check])
|
||||
}
|
||||
}
|
||||
|
||||
function mark(values, key, value) {
|
||||
if (value) {
|
||||
values[key] = value
|
||||
}
|
||||
}
|
||||
23
node_modules/property-information/lib/util/info.js
generated
vendored
Normal file
23
node_modules/property-information/lib/util/info.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = Info
|
||||
|
||||
var proto = Info.prototype
|
||||
|
||||
proto.space = null
|
||||
proto.attribute = null
|
||||
proto.property = null
|
||||
proto.boolean = false
|
||||
proto.booleanish = false
|
||||
proto.overloadedBoolean = false
|
||||
proto.number = false
|
||||
proto.commaSeparated = false
|
||||
proto.spaceSeparated = false
|
||||
proto.commaOrSpaceSeparated = false
|
||||
proto.mustUseProperty = false
|
||||
proto.defined = false
|
||||
|
||||
function Info(property, attribute) {
|
||||
this.property = property
|
||||
this.attribute = attribute
|
||||
}
|
||||
28
node_modules/property-information/lib/util/merge.js
generated
vendored
Normal file
28
node_modules/property-information/lib/util/merge.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var Schema = require('./schema')
|
||||
|
||||
module.exports = merge
|
||||
|
||||
function merge(definitions) {
|
||||
var length = definitions.length
|
||||
var property = []
|
||||
var normal = []
|
||||
var index = -1
|
||||
var info
|
||||
var space
|
||||
|
||||
while (++index < length) {
|
||||
info = definitions[index]
|
||||
property.push(info.property)
|
||||
normal.push(info.normal)
|
||||
space = info.space
|
||||
}
|
||||
|
||||
return new Schema(
|
||||
xtend.apply(null, property),
|
||||
xtend.apply(null, normal),
|
||||
space
|
||||
)
|
||||
}
|
||||
18
node_modules/property-information/lib/util/schema.js
generated
vendored
Normal file
18
node_modules/property-information/lib/util/schema.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = Schema
|
||||
|
||||
var proto = Schema.prototype
|
||||
|
||||
proto.space = null
|
||||
proto.normal = {}
|
||||
proto.property = {}
|
||||
|
||||
function Schema(property, normal, space) {
|
||||
this.property = property
|
||||
this.normal = normal
|
||||
|
||||
if (space) {
|
||||
this.space = space
|
||||
}
|
||||
}
|
||||
15
node_modules/property-information/lib/util/types.js
generated
vendored
Normal file
15
node_modules/property-information/lib/util/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
var powers = 0
|
||||
|
||||
exports.boolean = increment()
|
||||
exports.booleanish = increment()
|
||||
exports.overloadedBoolean = increment()
|
||||
exports.number = increment()
|
||||
exports.spaceSeparated = increment()
|
||||
exports.commaSeparated = increment()
|
||||
exports.commaOrSpaceSeparated = increment()
|
||||
|
||||
function increment() {
|
||||
return Math.pow(2, ++powers)
|
||||
}
|
||||
Reference in New Issue
Block a user