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

remark-table-comparify

v0.3.0

Published

Remark plugin to perform comparisons in a table

Downloads

5

Readme

remark-table-comparify

Plugin for Remark to perform comparisons in a table by assigning values and calculating scores.

example

Install

npm install remark-table-comparify

Usage

import { remark } from 'remark';
import remarkGfm from 'remark-gfm';  /* Needs remark-gfm */
import remarkTC from 'remark-table-comparify';

const file = 'Todo.md';

const remarked = await remark()
    .use(remarkGfm) /* Be sure to use the remark-gfm plugin before */
    .use(remarkTC, opts)
    .process(input)

if (remarked.data.tableComparify.altered) {
  /* A table was found and altered */
}

CLI

  • Install Remark CLI, [Remark GFM], and this plugin globally:

    npm i -g remark-cli remark-gfm remark-table-comparify
  • Run:

    remark . --use remark-gfm --use remark-table-comparify --output

VS Code

Doesn't work yet because this plugin uses ESM but VSCode/Electron doesn't (yet). Shall be fixed by electron#21457👀👍. Once resolved,

  • Install https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-remark
  • Install this plugin globally:
    npm i -g remark-table-comparify
  • Configure remark.format.plugins
    "remark.format.plugins": ["remark-table-comparify"]

API

remarkTC(opts)
  • opts [object] Options
  • opts.operations [object] Operations in the form of: { ['+']: (a, b) => a + b }
  • opts.resultSymbol [string='='] Symbol used to identify results column. E.g.: …| =result |…
  • opts.modifierSeparator [string=':'] Symbol used to identify modifiers. E.g.: …| +col:*2 |…
  • opts.defaultSeparator [string='?'] Symbol used to identify default value. E.g.: …| +col?1 |…

file.data.tableComparify is populated with:

  • found [boolean] If a table was found
  • altered [boolean] If a table was altered

Example

Imagine you're a cute fuzzy bunny with an evil plan to take over the forest and establish your BoingoSnax empire.

A simple Todo list won't do. You use something like the Eisenhower Method to fine-tune your plan by assigning Urgency/Importance points to each task.

This plugin can then help you calculate the score!

| Task                     | +Urgency:*10 | +Importance | +Significance | Effort | =Score |
| :----------------------- | -----------: | ----------: | ------------: | -----: | -----: |
| Take down Muffin Man     |           10 |          10 |             1 |      4 |    111 |
| Ruin Red                 |            9 |           9 |             2 |      5 |    101 |
| Act cute & fuzzy         |            8 |           8 |             3 |      1 |     91 |
| Steal Recipe Book!!      |            7 |           7 |             4 |     10 |     81 |
| Send Wolf on goose chase |            6 |           6 |             5 |      3 |     71 |
| Pick up dry cleaning     |            5 |           5 |             6 |      2 |     61 |
| Pay evil ski team        |            4 |           4 |             7 |      1 |     51 |
| Pay gas bill             |            3 |           3 |             8 |      2 |     41 |
| Call mom                 |            2 |           2 |             9 |      1 |     31 |
| Finish lair              |            1 |           1 |            10 |     10 |     21 |
  • Mathematical operators: It looks for mathematical operation symbols: +, -, *, / prefixed in the header row of columns and uses them to calculate the final result.

  • Result: The final result is saved in the column with a = sign in its header.

  • Modifiers: It looks for modifiers in the header suffixed with a : to further modify the score.

  • Defaults: It looks for a default value (with ?n) to use for empty cell

example

Header | What it does --|-- +Importance | Adds the value of cells of that column to the corresponding result column. +Urgency:*10 | Adds 10 times the value of that column +Effort?0 | Uses 0 as the default value (if absent/empty) =Score | Sets the result column.