Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

htmljs-parser

Package Overview
Dependencies
Maintainers
5
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmljs-parser - npm Package Compare versions

Comparing version 5.0.4 to 5.1.0

2

dist/core/Parser.d.ts

@@ -35,3 +35,3 @@ import { STATE, Range, ParserOptions as Options, ErrorCode } from "../internal";

read(range: Range): string;
positionAt(index: number): import("../internal").Position;
positionAt(offset: number): import("../internal").Position;
locationAt(range: Range): import("../internal").Location;

@@ -38,0 +38,0 @@ enterState<P extends Meta>(state: StateDefinition<P>): P;

import { type ParserOptions, type Range } from "./internal";
export { TagType, ErrorCode, type ParserOptions as Handlers, type Position, type Location, type Ranges, type Range, } from "./internal";
export { TagType, ErrorCode, getLines, getLocation, getPosition, type ParserOptions as Handlers, type Position, type Location, type Ranges, type Range, } from "./internal";
/**

@@ -4,0 +4,0 @@ * Creates a new Marko parser.

@@ -24,3 +24,6 @@ var __defProp = Object.defineProperty;

TagType: () => TagType,
createParser: () => createParser
createParser: () => createParser,
getLines: () => getLines,
getLocation: () => getLocation,
getPosition: () => getPosition
});

@@ -71,22 +74,9 @@ module.exports = __toCommonJS(src_exports);

}
function getLoc(lines, range) {
const start = getPos(lines, 0, range.start);
const end = range.start === range.end ? start : getPos(lines, start.line, range.end);
function getLocation(lines, startOffset, endOffset) {
const start = getPosition(lines, startOffset);
const end = startOffset === endOffset ? start : getPosAfterLine(lines, start.line, endOffset);
return { start, end };
}
function getPos(lines, startLine, index) {
let max = lines.length - 1;
let line = startLine;
while (line < max) {
const mid = 1 + line + max >>> 1;
if (lines[mid] <= index) {
line = mid;
} else {
max = mid - 1;
}
}
return {
line,
character: index - lines[line]
};
function getPosition(lines, offset) {
return getPosAfterLine(lines, 0, offset);
}

@@ -112,2 +102,18 @@ function getLines(src) {

}
function getPosAfterLine(lines, startLine, index) {
let max = lines.length - 1;
let line = startLine;
while (line < max) {
const mid = 1 + line + max >>> 1;
if (lines[mid] <= index) {
line = mid;
} else {
max = mid - 1;
}
}
return {
line,
character: index - lines[line]
};
}

@@ -137,7 +143,7 @@ // src/core/Parser.ts

}
positionAt(index) {
return getPos(this.lines || (this.lines = getLines(this.data)), 0, index);
positionAt(offset) {
return getPosition(this.lines || (this.lines = getLines(this.data)), offset);
}
locationAt(range) {
return getLoc(this.lines || (this.lines = getLines(this.data)), range);
return getLocation(this.lines || (this.lines = getLines(this.data)), range.start, range.end);
}

@@ -2126,3 +2132,6 @@ enterState(state) {

TagType,
createParser
createParser,
getLines,
getLocation,
getPosition
});
import { type Parser } from "../internal";
import { Location, Position, Range } from "./constants";
import { Location, Position } from "./constants";
export declare function isWhitespaceCode(code: number): boolean;
export declare function getLoc(lines: number[], range: Range): Location;
export declare function getPos(lines: number[], startLine: number, index: number): Position;
/**
* Given a source code line offsets, a start offset and an end offset, returns a Location object with line & character information for the start and end offsets.
*/
export declare function getLocation(lines: number[], startOffset: number, endOffset: number): Location;
/**
* Given a source code line offsets and an offset, returns a Position object with line & character information.
*/
export declare function getPosition(lines: number[], offset: number): Position;
/**
* Scan through some source code and generate an array of offsets for each newline.
* Useful for generating line/column information for source code.
*/
export declare function getLines(src: string): number[];
export declare function htmlEOF(this: Parser): void;
{
"name": "htmljs-parser",
"description": "An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values",
"version": "5.0.4",
"version": "5.1.0",
"devDependencies": {

@@ -6,0 +6,0 @@ "@changesets/changelog-github": "^0.4.4",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc