🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
58
node_modules/property-information/lib/util/create.js
generated
vendored
Normal file
58
node_modules/property-information/lib/util/create.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* @typedef {import('./schema.js').Properties} Properties
|
||||
* @typedef {import('./schema.js').Normal} Normal
|
||||
*
|
||||
* @typedef {Record<string, string>} Attributes
|
||||
*
|
||||
* @typedef {Object} Definition
|
||||
* @property {Record<string, number|null>} properties
|
||||
* @property {(attributes: Attributes, property: string) => string} transform
|
||||
* @property {string} [space]
|
||||
* @property {Attributes} [attributes]
|
||||
* @property {Array<string>} [mustUseProperty]
|
||||
*/
|
||||
|
||||
import {normalize} from '../normalize.js'
|
||||
import {Schema} from './schema.js'
|
||||
import {DefinedInfo} from './defined-info.js'
|
||||
|
||||
const own = {}.hasOwnProperty
|
||||
|
||||
/**
|
||||
* @param {Definition} definition
|
||||
* @returns {Schema}
|
||||
*/
|
||||
export function create(definition) {
|
||||
/** @type {Properties} */
|
||||
const property = {}
|
||||
/** @type {Normal} */
|
||||
const normal = {}
|
||||
/** @type {string} */
|
||||
let prop
|
||||
|
||||
for (prop in definition.properties) {
|
||||
if (own.call(definition.properties, prop)) {
|
||||
const value = definition.properties[prop]
|
||||
const info = new DefinedInfo(
|
||||
prop,
|
||||
definition.transform(definition.attributes || {}, prop),
|
||||
value,
|
||||
definition.space
|
||||
)
|
||||
|
||||
if (
|
||||
definition.mustUseProperty &&
|
||||
definition.mustUseProperty.includes(prop)
|
||||
) {
|
||||
info.mustUseProperty = true
|
||||
}
|
||||
|
||||
property[prop] = info
|
||||
|
||||
normal[normalize(prop)] = prop
|
||||
normal[normalize(info.attribute)] = prop
|
||||
}
|
||||
}
|
||||
|
||||
return new Schema(property, normal, definition.space)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue