npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fontoxpath-module-loader

v1.0.2

Published

Loads XQuery modules into [fontoxpath](https://github.com/FontoXML/fontoxpath) and does something with the result. Can be easily configured to load that module from disk, or from a REST endpoint, or whatever else async stuff you have.

Downloads

145

Readme

fontoxpath-module-loader

Loads XQuery modules into fontoxpath and does something with the result. Can be easily configured to load that module from disk, or from a REST endpoint, or whatever else async stuff you have.

Exposes the evaluateXPath function which is similar to fontoxpath.evaluateXPath, except that you give it the location of your "main" XQuery module and it will try to resolve any "library" XQuery modules from there.

Use

import { evaluateXPath, eva } from 'fontoxpath-module-loader';

const result = await evaluateXPath(
	// Given a target location and referrer, return the location.
	(referrer, target) => path.resolve(path.dirname(referrer), target),

	// Given a target location, return the contents of that XQuery module
	(target) => fs.readFileSync(target, 'utf8'),

	// The location of the main XQuery module
	'my-module-file.xqm'
);

Where my-module-file.xqm could contain, for example:

import module namespace foo = "https://foo.bar" at "./my-other-xquery-example.xql";

foo:do-something()

evaluateXPath()

Runs a query and returns the result to you. Is the same as fontoxpath.evaluateXPath with exception of the first three arguments:

| n | Name & type | Description | |-----|-----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1. | resolveLocation (referrer: string, target: string): Promise<string> | Translates a potentially relative file reference to an absolute file reference. Used to resolve one module referring to another one. May return a promise. | | 2. | resolveContent (target: string): Promise<string> | Download/steal/borrow the XQuery module source that belongs to the given target location. May return a promise. | | 3. | location: string | The location of your main XQuery module. |

Please revise the fontoxpath documentation for the other arguments of evaluateXPath:

| n | Name & type | Description | |-----|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 4. | contextNode?: fontoxpath.Node | Is exactly the contextNode argument that would normally be passed to fontoxpath.evaluateXPath. | | 5. | domFacade?: fontoxpath.IDomFacade | Is exactly the domFacade argument that would normally be passed to fontoxpath.evaluateXPath. | | 6. | variables?: object | Is exactly the variables argument that would normally be passed to fontoxpath.evaluateXPath. | | 7. | returnType?: number | Is exactly the returnType argument that would normally be passed to fontoxpath.evaluateXPath. | | 8. | options?: any | Is exactly the options argument that would normally be passed to fontoxpath.evaluateXPath. The language property defaults to fontoxpath.evaluateXPath.XQUERY_3_1_LANGUAGE |

Returns a node, string, boolean, number, array, object or null based on the expression in your XQuery module file.

evaluateUpdatingExpression()

Runs a query, updates the given DOM in place, and potentially also returns a result to you. Is the same as fontoxpath.evaluateUpdatingExpression with exception of the first three arguments:

| n | Name & type | Description | |-----|-----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1. | resolveLocation (referrer: string, target: string): Promise<string> | Translates a potentially relative file reference to an absolute file reference. Used to resolve one module referring to another one. May return a promise. | | 2. | resolveContent (target: string): Promise<string> | Download/steal/borrow the XQuery module source that belongs to the given target location. May return a promise. | | 3. | location: string | The location of your main XQuery module. |

Please revise the fontoxpath documentation for the other arguments of evaluateUpdatingExpression:

| n | Name & type | Description | |-----|-------------------------------------|----------------------------------------------------------------------------------------------------| | 4. | contextNode?: fontoxpath.Node | Is exactly the contextNode argument that would normally be passed to fontoxpath.evaluateXPath. | | 5. | domFacade?: fontoxpath.IDomFacade | Is exactly the domFacade argument that would normally be passed to fontoxpath.evaluateXPath. | | 6. | variables?: object | Is exactly the variables argument that would normally be passed to fontoxpath.evaluateXPath. | | 7. | options?: any | Is exactly the options argument that would normally be passed to fontoxpath.evaluateXPath. |

Will apply any updates as per your XQUF expression to the given contextNode. Additionally, your XQUF may return something which results in this function resolving to that node, string, number, similar to what evaluateXPath would return.