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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a-la/context

v1.4.0

Published

A test context for @a-la packages.

Downloads

270

Readme

@a-la/context

npm version

@a-la/context is a a test context for @a-la packages used in alamode transpiler. It will provide a means to record the result of transforms for given rules, as well as emitted events.

yarn add -E @a-la/context

Table Of Contents

API

The package is available by importing its default function:

import ÀLaContext from '@a-la/context'

The context is then passed to the context property of Zoroaster tests suites.

async stream(  rules: Rule|Rule[],  text: string,  eventKeys?: string[],): ReturnType

Creates a Replaceable stream according to a rule or set of rules, asynchronously ends it with passed text and returns the outcome.

In the example below, a transform rule is used to replace an export statement with a module.exports statement, and emit an exports event.

/**
 * A rule to replace an `export function` statement with `module.exports`.
 */
export const exportFunctionRule = {
  re: / *export function ([$_\w][$_\w\d]*)/gm,
  replacement(_, fn) {
    // async
    this.emit('exports', fn)

    // sync
    this.exports = this.exports || []
    this.exports.push(fn)

    return `module.exports.${fn} = function ${fn}`
  },
}

Now, this rule can be tested using the @a-la/context and zoroaster testing framework.

import { equal, deepEqual } from '@zoroaster/assert'
import ÀLaContext from '@a-la/context'
import { exportFunctionRule as rule } from '../../src/rule'

/** @type {Object.<string, (c: ÀLaContext)>} */
const T = {
  context: ÀLaContext,
  async 'replaces the export function'({ stream }) {
    const fn = 'test'
    const data = `export function ${fn}() {}`

    const {
      result,
      events,
      replaceable,
    } = await stream(rule, data, ['exports'])
    const expected = `module.exports.${fn} = function ${fn}() {}`
    equal(result, expected)
    deepEqual(events, {
      exports: [fn],
    })
    deepEqual(replaceable.exports, [fn])
  },
}

export default T
example/test/spec
  ✓  replaces the export function

🦅  Executed 1 test.

The output of the stream function is an object described below.

ReturnType: Replaceable instance, string result and events map.

| Name | Type | Description | | ---------------- | ------------------------------------ | -------------------------------------------------------- | | events* | Object<string, any[]> | Emitted events recorded against passed events keys. | | result* | string | The caught output of a Replaceable stream as a string. | | replaceable* | Replaceable | The instance of a Replaceable stream. |

setConfig(  config: Object,): void

This method allows to set the config property of the Replaceable instance created inside of the stream method. Some transform may use config for certain functionality, e.g., replacing of the source string in the @a-la/import transform.

setFile(  file: string,): void

Sets the file property on the replaceable stream. This is required by the import transform to find the package.json file of the imported module to check whether it has the alamode property so that the esCheck can be skipped.

setProps(  props: !Object,): void

Assigns properties to the transform stream. The rules will be able to access them via their this context.

Copyright