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

jtc

v0.1.6

Published

JTC(Json To {CODE})compiles an AST input data in to any code output based on provided/default descriptor

Downloads

3

Readme

build pass Test Coverage Code Climate npm downloads

JTC - Json To {CODE} Compiler

JTC is a json to any code transformer

What It Does:

  1. takes a tokenized code tree input in form of javaScript {Object}
  2. combines that with by default embedded or provided descriptor
  3. bakes the code together and gives back a {String} result

Installation

To install the stable version:

npm install --save jtc

Usage

  import jtc from 'jtc';

  let jtcResult = jtc(compilerInput, userLoadedDescriptor);

Compiler input (compilerInput)

  • this the AST data you gather on your app's side

  • goes in this form:

  {
    slug: 'slugifiedTestName',
    describe: {
        text: 'dis is a spec description',
        body: [ {
                beforeAll: {
                    body: {
                        value: 'SOME STRING VALUE1'
                    }
                },
              },
              {
                step: {
                  text: 'dis is a step description',
                  body: [
                      {
                        click: {
                          text: 'some text',
                          selector: '[data-ft=some-valid-selector2]'
                        }
                      },
                      {
                        click: {
                          text: 'some text',
                          selector: '[data-ft=some-valid-selector3]'
                        }
                      },
                      {
                        expect: {
                          text: 'some text',
                          expectCondition: 'someMethod("[data-ft=some-valid-selector1]")',
                          toBeCallback: 'toEqual',
                          passCondition: '"I expect nothing, but the truth!"'
                          assertMessage: 'AssertMessage: Well Damn!',
                        }
                      }
                    ]
                }
              },
              {
                afterAll: {
                    body: {
                        value: 'SOME STRING VALUE2'
                    }
                }
              }
            ]
          }
      }
  • the only thing compiler cares about is correspondence between top-level key like 'describe', for example, with it's presence in descriptor

  • if the key is present in descriptor -> compiler is going to merge start and end together and will add nested children if there is a body[] array there

Descriptor (userLoadedDescriptor)

  • Descriptor is a JSON formatted normalized representation of each code block that can come from compilerInput

  • goes in this form:

{
  describe: {
    spec: {
      start: 'describe("{{describe.text}}", () => {',
      end: '});',
      enumerable: true
    },
    wrapper: {
      spec : {
        start: 'export function {{describe.slug}}() {',
        end: '}'
      }
  },
  step: {
    spec: {
      start: 'it("{{step.text}}", (done) => {',
      end: '});',
      enumerable: true
    }
  },
  click: {
    spec: {
      start: 'yourMethodToTriggerCliks("{{{click.selector}}}")',
      end: ''
    }
  },
  log: {
    spec: {
      start: 'yourLogMethod("{{{log.text}}}")',
      end: ''
    }
  },
  expect: {
    spec: {
      start: 'expect({{{expect.expectCondition}}}).{{{expect.toBeCallback}}}({{{expect.successCondition}}}, "{{{expect.assertMessage}}}") \n',
      end: ''
    }
  }
}
  • each top level key represents a code block that should be described

  • required properties for each code block description are: <TOP_LEVEL_KEY_CODE_BLOCK_NAME> : { spec: { start: '<STRING_DESCRIPTION_OF_CODE_BLOCK_START>', end: '<STRING_DESCRIPTION_OF_CODE_BLOCK_END>' } }

  • optional fields for each code block description are:

    enumerable -> means there might be code blocks inside of this code block

    wrapper -> specifies a wrapper around this code block.Each block can contain N number of wrappers around

  • compiler is using handlebars as template-processor, so in order to reach a property passed from client you need to specify it in a way: {{<TOP_LEVEL_KEY_CODE_BLOCK_NAME>.<VALUE_PROPERTY_YOU_WANT_TO_REACH>}}

Compiler output (jtcResult)

  • compiler returns back a compiled non-beautyfied string which can be consumed by a string formatter of choice

Usage Examples

  • Coming soon

Documentation

  • TODO

License

MIT