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

postdfm

v9.0.0

Published

Provides an API for easily transforming Delphi Forms

Downloads

100

Readme

postdfm

Process over Delphi Forms (.dfm) files via an AST.

Inspired by the excellent PostCSS tool, motivated by my rage at the Delphi IDE.

npm Continuous Integration Continuous Deployment Codecov branch

Table of Contents

Installation

The postdfm project is an interface wrapping all the separate modules together.

# npm
$ npm install postdfm

# yarn
$ yarn add postdfm

Example Usage

import fs from "fs";
import postdfm from "postdfm";

// only if implementing your own plugin
import { Plugin } from "@postdfm/plugin";

class SomePlugin extends Plugin {
  install(hooks) {
    hooks.string.tap(ast => {
      // manipulate AST here
    }

    // all AST types can be manipulated, see AST.ASTTypes

    // also available:
    // - "after" hook for certain types
    hooks.after.object.tap(ast => {
      // manipulate AST here
    })
    // - "all" hook for everything - excludes "after" hooks
    hooks.all.tap(ast => {
      // manipulate AST here
    })
  }
}

const cisDfm = fs.readFileSync(
  "cis.dfm",
  //.dfm files tend to be ascii instead of utf8
  "ascii"
);

const runner = postdfm({
  transformers: [new SomePlugin()],
});

const transDfm = runner.processSync(dfm, {
  //filename used for reporting errors
  from: "cis.dfm",
});

fs.writeFileSync("trans.dfm", transDfm);

Reference

Runner instance

Create a runner by calling the postdfm function.

import postdfm from "postdfm";

const runner = postdfm();

postdfm(options?: RunnerOptions)

Create a Runner instance using RunnerOptions

runner.process(dfm: string, processingOptions: ProcessingOptions): Promise<string>

Process a file through the runner asynchronously.

runner.processSync(dfm: string, processingOptions: ProcessingOptions): string

Process a file through the runner synchronously.

RunnerOptions

Options to pass to an instance of Runner.

options.plugins: Plugin[]

Array of transformations to perform on AST.

options.parser: Parser = "@postdfm/dfm2ast"

Parser to use, defaults to @postdfm/dfm2ast.

options.stringifier: Stringifier = "@postdfm/ast2dfm"

Stringifier to use, defaults to @postdfm/ast2dfm.

Plugin

A class that extends the @postdfm/plugin Plugin, extending the install() method.

See @postdfm/plugin for more information.

Parser

A function that takes a string, parses it, and returns an AST.

(dfm: string): AST.Root

Stringifier

A function that takes an AST, stringifies it, and returns a string.

(ast: AST.Root): string

ProcessingOptions

processingOptions.from

The file which is being processed. Used when throwing syntax errors.

Documentation

You can find the generated typedoc documentation here.

Contributing

Bug reports and feature requests are greatly appreciated, as are pull requests.

Please see the Contributing Guide for instructions on how to contribute to this project.

License

Licensed under the MIT License.