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

@foldmaker/tiny

v0.0.1

Published

Reduced version of Foldmaker

Downloads

1

Readme

foldmaker-tiny

This is a reduced version of Foldmaker that only exposes Foldmaker and tokenize functions, and f class. Great for figuring out how Foldmaker works, since core utilities are tokenize function and parse method. The aim is to see how tiny Foldmaker's algorithm can be. FoldmakerObject class (f in this case), only has parse, _replace, add methods. These methods are oftenly adequate for tree generation.

Differences from the main version:

  • There is no replace, traverse methods and visitor helper.
  • Is not easily pluggable like the main version.
  • parse method does not set '1' for unset token types.
  • parse method does not have debug callback as the last argument.
  • parse method does not have props key in its callback argument, as soon as you won't do something like source mapping this is not important though.

Most Foldmaker examples that uses no more than Foldmaker, tokenize, visitor and parse method should also be able to work with this version. There is only the following slight change:

While parse method works like this in Foldmaker:

parse([visitor(regex1, fn1), visitor(regex2, fn2)])
parse(regex1,fn1)

In this version, it works like this:

parse([regex1, fn1], [regex2, fn2])
parse([regex1, fn1])

When minified, whole code looks like this:

class f{constructor(e){let t=e;this.types=t?e.map(e=>e.type).join(""):"",this.values=t?e
.map(e=>e.value):[]}parse(...e){(e=e.map(([e,t])=>[t,e])).push([()=>void 0,/[\s\n\S]/]);
let t=this;do{t=t._replace(t,e)}while(!0===t.m);return t}add(e,t){this.types+=e,this
.values=this.values.concat(t)}_replace({types:e,values:t},a){let l=new f;return tokenize
(e,a,({type:e,map:a,index:s})=>{let i=a[0].length,n={raw:t.slice(s,i+s),index:s,count:i,
map:a},p=e(n);p?(l.add(p[0],[p[1]]),l.m=!0):l.add(n.map[0],n.raw)}),l}}tokenize=(
(e,t,a)=>{let l=0,s=[];for(t.push(["0",/[\s\n\S]/]);e;)t.some(([t,i])=>{let n=i.exec(e);
if(n&&n.index<1){let i=n[0],p=a?a({type:t,value:i,map:n,index:l}):{type:t,value:i};
return p&&s.push(p),e=e.slice(i.length),l+=i.length,!0}});return s});let Foldmaker=e=>new f(e);