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

inline-js-default-transforms

v0.1.2

Published

Builtin transformers for inline-js

Downloads

50

Readme

inline-js-default-transforms

Build Status codecov install size

This repository contains builtin transformers for inline-js

Installation

npm install inline-js-default-transforms

Usage

const {createInliner} = require("inline-js-core");
const {TRANSFORMS} = require("inline-js-default-transforms");

const inliner = createInliner();
TRANSFORMS.forEach(inliner.transformer.add);

TRANSFORMS

cssmin

Minify css content.

dataurl

Convert the content into data URL.

The transformer would determine the mimetype from the filename:

// data:text/css;charset=utf8;base64,...
$inline("mystyle.css|dataurl")

// data:image/png;base64,...
$inline("myimage.png|dataurl")

Or you can pass the mimetype manually:

$inline("somefile.txt|dataurl:text/css")

Specify charset (default to utf8 for text files):

$inline("somefile.txt|dataurl:text/css,utf8")

docstring

Extract docstring (i.e. the top-most template literal) from the content.

eval

Evaluate JavaScript expression. You can access the content with $0.

var version = $inline("./package.json|eval:JSON.parse($0).version|stringify");

indent

Indent the string according to the indent of the current line.

entry.js

function test() {
  $inline("foo.js|indent");
}

foo.js

console.log("foo");
console.log("bar");

inlinejs entry.js result:

function test() {
  console.log("foo");
  console.log("bar");
}

markdown

Wrap content with markdown codeblock, code, or quote.

// a.txt
some text

// $inline("a.txt|markdown:codeblock")
```
some text
```

// $inline("a.txt|markdown:codeblock,js")
```js
some text
```

// $inline("a.txt|markdown:code")
`some text`

// $inline("a.txt|markdown:quote")
> sometext

parse

JSON.parse the content. You can access properties by specifying key name.

var version = $inline("./package.json|parse:version"),
  nestedProp = $inline("./package.json|parse:nested,prop");

string

If the content is a buffer, convert it into a utf8 string. Otherwise do nothing.

stringify

JSON.stringify the content. Useful to include text content into JavaScript code:

var myCssString = $inline("./style.css|cssmin|stringify");

trim

String.prototype.trim the content.

Changelog

  • 0.1.2 (Jun 6, 2020)

    • Fix: make indent work with $inline.start.
    • Add: support language mark in markdown:codeblock.
  • 0.1.1 (Jun 28, 2018)

    • Fix: exclude test files from the package.
  • 0.1.0 (Jun 27, 2018)

    • Split out from inline-js.