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

@fnet/expression

v0.1.22

Published

## Introduction The `@fnet/expression` project is designed to help users parse and analyze structured expressions that consist of processor and statement components. This tool can be particularly useful for those who need to dissect complex expressions in

Downloads

354

Readme

@fnet/expression

Introduction

The @fnet/expression project is designed to help users parse and analyze structured expressions that consist of processor and statement components. This tool can be particularly useful for those who need to dissect complex expressions into more manageable parts, allowing for easier understanding and processing.

How It Works

The project works by taking a structured expression and breaking it down into its basic components: processors and statements. It uses a recursive parsing method to handle nested expressions while respecting a maximum depth to prevent too deep recursion. The expression is analyzed to extract all processors, presenting a clear hierarchy and order of the components.

Key Features

  • Recursive Parsing: Efficiently breaks down expressions into individual components, even handling nested structures.
  • Processor Extraction: Gathers all processor elements from the expression, providing an ordered list.
  • Depth Management: Prevents overly deep recursion by setting a limit, ensuring performance and reliability.

Conclusion

The @fnet/expression project is a straightforward and practical tool for parsing and analyzing structured expressions. It offers users a reliable method to dissect intricate expressions into simpler parts, making them easier to work with and understand.

Developer Guide for @fnet/expression

Overview

The @fnet/expression library provides tools to parse and process structured expressions. Built with ease of use in mind, the library focuses on breaking down expression strings into their components and extracting information such as processors and statements from them. This can be particularly useful for applications that utilize scripting or configurations defined in domain-specific languages.

Installation

To use @fnet/expression in your project, you can install it via npm or yarn:

npm install @fnet/expression

or

yarn add @fnet/expression

Usage

The library exposes a straightforward public API for parsing expressions. Below is an example of how you can utilize it within your application:

import parseExpression from '@fnet/expression';

(async () => {
    const expression = 'foo::bar baz::nested quux';
    const parsedResult = await parseExpression({ expression });

    if (parsedResult) {
        console.log(parsedResult.processor); // Output: foo
        console.log(parsedResult.process.order); // Output: ['foo', 'baz']
        console.log(parsedResult.process.statement); // Output: nested quux
    } else {
        console.log('Expression could not be parsed');
    }
})();

Examples

Basic Expression Parsing

import parseExpression from '@fnet/expression';

(async () => {
    const expression = 'action::do_something';
    const parsedResult = await parseExpression({ expression });

    console.log(parsedResult);
    // Output:
    // {
    //     processor: 'action',
    //     statement: 'do_something',
    //     expression: 'action::do_something',
    //     process: {
    //         statement: 'do_something',
    //         order: ['action']
    //     }
    // }
})();

Complex Nested Expressions

import parseExpression from '@fnet/expression';

(async () => {
    const expression = 'outer::inner::deepest';
    const parsedResult = await parseExpression({ expression });

    console.log(parsedResult);
    // Output:
    // {
    //     processor: 'outer',
    //     statement: 'inner::deepest',
    //     expression: 'outer::inner::deepest',
    //     process: {
    //         statement: 'deepest',
    //         order: ['outer', 'inner']
    //     },
    //     next: {
    //         processor: 'inner',
    //         statement: 'deepest',
    //         expression: 'inner::deepest',
    //         next: {
    //             processor: 'deepest',
    //             statement: '',
    //             expression: 'deepest'
    //         }
    //     }
    // }
})();

Acknowledgement

The development of @fnet/expression has been backed by contributions from various developers. The library may use code or draw concepts from external resources, and we extend our gratitude to the authors and maintainers of those projects for their work in advancing open-source software development.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  expression:
    type: string
    description: The expression to be parsed in the format of "processor::statement".
required:
  - expression