New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@pomsky-lang/unplugin

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pomsky-lang/unplugin

Use Pomsky along with your JavaScript.

latest
Source
npmnpm
Version
1.2.10
Version published
Maintainers
2
Created
Source

Unplugin Pomsky

Use Pomsky along with your JavaScript.

Support

  • ESM
  • CJS
  • Vite
  • Rollup
  • Webpack
  • ESBuild

Installation

pnpm i -D @pomsky-lang/unplugin

vite.config.ts

import fs from "node:fs";
import pomsky from "@pomsky-lang/unplugin";
import { UserConfigExport } from "vite";

export default {
	plugins: [
		pomsky.vite({
			flavor: "js", // default = "js"
			includeOriginal: false, // default = false
			fileExtensions: [".javascript"], // default = []; always checks /"." ["c" "m"]? ["j" "t"] "s" "x"? $/
			pomskyWASM: fs.readFileSync("path/to/custom/pomsky.wasm"), // default = unplugin-pomsky's package.json pomsky-wasm
		}),
	],
} as UserConfigExport;

tsconfig.json

{
	"compilerOptions": {
		"types": ["@pomsky-lang/unplugin"]
	}
}

Usage

Import

// The regex source is inlined and the Pomsky code is compiled on build.
// The flavor is optional.
import make, { pomsky, regex } from "./regex.pom?flavor=rust";

// Compiles the regex when called.
make();

// Optional flags.
make("gi");

// Automatic caching. Works with flags too!
for (let i = 0; i < 1_000_000; i++) {
	make();
}

// The original Pomsky source. Only included with `includeOriginal: true` in the plugin options.
pomsky;

// The regex source.
regex;

Inline

// The regex source is inlined and the Pomsky code is compiled on buid.

// No need to import this function since it doesn't actually exist.
// The flavor is optional.
const make = pomsky$(`
['-+']?
%
('0' | ['1'-'9'] (','? ['0'-'9'])*)
('.' ['0'-'9']+)?
%
`, "js");

// Compiles the regex when called.
make();

// Optional flags.
make("gi");

// Automatic caching. Works with flags too!
for (let i = 0; i < 1_000_000; i++) {
	make();
}

// The original Pomsky source. Only included with `includeOriginal: true` in the plugin options.
make.pomsky;

// The regex source.
make.regex;

Unicode Aware

Pomsky is unicode aware by default, so the unicode flag is enabled by default.

There's no clean way to represent disabling unicode with the standard string format, so the plugin provides an object form which has the ability to disable unicode.

make().flags; // "u"
make("").flags; // "u"
make("i").flags; // "iu"
make({ ignoreCase: true, unicode: false }).flags; // "i"

Keywords

unplugin

FAQs

Package last updated on 11 Mar 2023

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