🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
27
node_modules/unist-util-remove-position/lib/index.d.ts
generated
vendored
Normal file
27
node_modules/unist-util-remove-position/lib/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Remove the `position` field from a tree.
|
||||
*
|
||||
* @template {Node} Tree
|
||||
* Node type.
|
||||
* @param {Tree} tree
|
||||
* Tree to clean.
|
||||
* @param {Options | boolean | null | undefined} [options]
|
||||
* Configuration.
|
||||
* @returns {Tree}
|
||||
* The given, modified, `tree`.
|
||||
*/
|
||||
export function removePosition<
|
||||
Tree extends import('unist').Node<import('unist').Data>
|
||||
>(tree: Tree, options?: Options | boolean | null | undefined): Tree
|
||||
export type Node = import('unist').Node
|
||||
/**
|
||||
* Configuration.
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Whether to use `delete` to remove `position` fields.
|
||||
*
|
||||
* The default is to set them to `undefined`.
|
||||
*/
|
||||
force?: boolean | null | undefined
|
||||
}
|
||||
48
node_modules/unist-util-remove-position/lib/index.js
generated
vendored
Normal file
48
node_modules/unist-util-remove-position/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @typedef {import('unist').Node} Node
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {boolean | null | undefined} [force=false]
|
||||
* Whether to use `delete` to remove `position` fields.
|
||||
*
|
||||
* The default is to set them to `undefined`.
|
||||
*/
|
||||
|
||||
import {visit} from 'unist-util-visit'
|
||||
|
||||
/**
|
||||
* Remove the `position` field from a tree.
|
||||
*
|
||||
* @template {Node} Tree
|
||||
* Node type.
|
||||
* @param {Tree} tree
|
||||
* Tree to clean.
|
||||
* @param {Options | boolean | null | undefined} [options]
|
||||
* Configuration.
|
||||
* @returns {Tree}
|
||||
* The given, modified, `tree`.
|
||||
*/
|
||||
// To do: next major: return `void`.
|
||||
// To do: remove `force` shortcut, replace with options.
|
||||
export function removePosition(tree, options) {
|
||||
const force =
|
||||
typeof options === 'boolean' ? options : options ? options.force : false
|
||||
|
||||
visit(tree, remove)
|
||||
|
||||
return tree
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
*/
|
||||
function remove(node) {
|
||||
if (force) {
|
||||
delete node.position
|
||||
} else {
|
||||
node.position = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue