Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
28
Frontend-Learner/node_modules/comment-parser/src/transforms/indent.ts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/comment-parser/src/transforms/indent.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Transform } from './index.js';
|
||||
import { Block, Line } from '../primitives.js';
|
||||
import { rewireSource } from '../util.js';
|
||||
|
||||
const pull = (offset: number) => (str) => str.slice(offset);
|
||||
const push = (offset: number) => {
|
||||
const space = ''.padStart(offset, ' ');
|
||||
return (str) => str + space;
|
||||
};
|
||||
|
||||
export default function indent(pos: number): Transform {
|
||||
let shift: (string: string) => string;
|
||||
const pad = (start: string) => {
|
||||
if (shift === undefined) {
|
||||
const offset = pos - start.length;
|
||||
shift = offset > 0 ? push(offset) : pull(-offset);
|
||||
}
|
||||
return shift(start);
|
||||
};
|
||||
|
||||
const update = (line: Line): Line => ({
|
||||
...line,
|
||||
tokens: { ...line.tokens, start: pad(line.tokens.start) },
|
||||
});
|
||||
|
||||
return ({ source, ...fields }: Block): Block =>
|
||||
rewireSource({ ...fields, source: source.map(update) });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue