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

jsot-bh

v0.5.0

Published

BH wrapper for JSOT template engine

Downloads

39

Readme

JSOT-BH NPM version Build Status Dependency Status Coveralls Status

This is modification of JSOT template engine, which provides BH matchers and some other things.

Migration notice

This library is not maintained by BH developers and can't be used as as-is replace for bh package. Use with cautition!

Matchers

Matcher - function passed as second argument to BH.match.

It accepts context object with helper methods (which essential just an instance of JSOT-BH) and current processed object as second argument.

It can call applyBase method of context object, which applies all matchers to current processed object.

It can return new object as replacement of current object (useful for wrapping) - which can contain current object in content property or in an arrary.

JSOT-BH will restart apply procedure for returned object until it will be processed with all matchers, that corresponds to this block.

API

Context methods is similar to BH specification.

Usage

var JSOTBH = require('./index.js');
var jsotbh = new JSOTBH();

jsotbh.match('html', function (ctx) {
    ctx.tag('html');
});

jsotbh.match('p', function (ctx) {
    ctx.tag('p');
});

jsotbh.match('p_bold_yes', function (ctx) {
    ctx.cls('boldy');
});

console.log(
    jsotbh.apply({
        block: 'html',
        content: [
            { block: 'p', content: 'You' },
            { block: 'p', mods: { bold: 'yes' }, content: 'Rock!' }
        ]
    })
);

// should output: '<html class="html"><p class="p">You</p><p class="p p_bold_yes boldy">Rock!</p></html>'

Benchmark

This numbers can be used as "fastest possible" BH performance, but not necessary achivable (jsot-bh is lacking some functionality - see API status for details).

While single block/element rendering is much faster, than BH, real-life pages is rendered slower, than BH (by 7%).

Benchmarking applyBase...
  jsotbh#block          x 135,141 ops/sec ±1.17% (90 runs sampled)
  bh#block              x  21,956 ops/sec ±2.35% (86 runs sampled)

Benchmarking block matching...
  jsotbh#block          x 1,059,293 ops/sec ±3.61% (93 runs sampled)
  bh#block              x    62,714 ops/sec ±2.20% (88 runs sampled)

Benchmarking block_mod matching...
  jsotbh#block_mod      x 529,408 ops/sec ±0.91% (94 runs sampled)
  bh#block_mod          x  49,560 ops/sec ±2.65% (80 runs sampled)

Benchmarking element matching...
  jsotbh#block__elem    x 212,603 ops/sec ±1.20% (92 runs sampled)
  bh#block__elem        x  47,530 ops/sec ±2.65% (80 runs sampled)

Benchmarking deep bemjsons...
  jsotbh#deep           x 11,085 ops/sec ±1.12% (92 runs sampled)
  bh#deep               x  8,311 ops/sec ±1.52% (86 runs sampled)

Benchmarking deepArray bemjsons...
  jsotbh#deepArray      x 18,638 ops/sec ±1.90% (88 runs sampled)
  bh#deepArray          x 17,555 ops/sec ±1.34% (84 runs sampled)

Benchmarking block wrapping...
  jsotbh#wrap           x 201,079 ops/sec ±1.54% (78 runs sampled)
  bh#wrap               x  48,531 ops/sec ±3.50% (83 runs sampled)