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

ts-xpath

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-xpath

XPath Parser for TypeScript

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47
increased by42.42%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

ts-xpath

This is a modified version of js-xpath. It is adapted for use with TypeScript and is compiled using npm run build.

Usage

npm install ts-xpath
import { XPathParser } from 'ts-xpath';

let parser = new XPathParser();
let parsed = parser.parse("//node");

xpath-models.ts provides a default XPathModels which does not support the hashtag preprocessor. If you want to support hashtags within xpaths, you can use:

let hashtagConfig: XPathModels.HashtagConfig = {
  isValidNamespace: (namespace: string) => boolean,
  hashtagToXPath: (hashtagExpr: string) => string | null,
  toHashtag: (xpath: IXPathExpression) => string | null
}
parser.hashtagConfig = hashtagConfig;

hashtags use the format #namespace/arbitrarily/long/path and do not support filtering

Tests

  • Run npm run test to run tests.

Known Limitations

  • Filter expressions are not supported due to a known bug in jison.
  • See the failing tests for examples of expressions that are known not to work.

Build

This is built using jison. To build the parser file yourself run:

$ npm run build - This will build both the distribution (webpack) package in dist/ and rebuild the Jison parser (src/jison/xpath.js) from the src/jison/ files. $ npm run jison - Rebuild parser.js from the Jison specification files. $ npm run dist - Rebuild the browser friendly distribution from the current source files.

For more information on jison see the jison project website at: http://zaach.github.com/jison/.

Keywords

FAQs

Package last updated on 28 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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