Urara-Blog/node_modules/.pnpm-store/v3/files/dc/773844d59751a64b0d504d13a97bb7ec58c09031eb801054f1e677aaf57fce720eb18dbaf69bd5eb8f42bf45253264ac8fd51c56af9957370dba209ec8c34e
2022-08-14 01:14:53 +08:00

50 lines
890 B
Text

'use strict'
var own = {}.hasOwnProperty
module.exports = stringify
function stringify(value) {
// Nothing.
if (!value || typeof value !== 'object') {
return ''
}
// Node.
if (own.call(value, 'position') || own.call(value, 'type')) {
return position(value.position)
}
// Position.
if (own.call(value, 'start') || own.call(value, 'end')) {
return position(value)
}
// Point.
if (own.call(value, 'line') || own.call(value, 'column')) {
return point(value)
}
// ?
return ''
}
function point(point) {
if (!point || typeof point !== 'object') {
point = {}
}
return index(point.line) + ':' + index(point.column)
}
function position(pos) {
if (!pos || typeof pos !== 'object') {
pos = {}
}
return point(pos.start) + '-' + point(pos.end)
}
function index(value) {
return value && typeof value === 'number' ? value : 1
}