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

code-jinni

v2.1.1

Published

Generic javascript code generator that uses actual code snippets and mantains relationship ebtween artifacts to simplify DOM construction and eventual code generation

Downloads

7

Readme

code-jinni

codecov Build Status NPM Downloads Known Vulnerabilities Greenkeeper badge

The module allows to create a simple way to construct dom of code snippets that can be rendered at the end into javascript code.

One way to use it is to create templates for code generation with dynamic elements that can be related to each other. This would allow, for example, by changing base for some modules, it will modify imports in the module that imports the affected modules.

Install

yarn add code-jinni

Usage

External module

const { createModule } = require('code-generator');
const mod = createModule('foo');
console.log(mod.getPath()); // foo

Relative module

const { createModule, Location } = require('code-generator');

const root = new Location('some/path/to/root');
const foo = createModule(root.relative('foo'));
console.log(mod.getPath()); // some/path/to/root/foo

Adding import to the module

const { createModule, Location } = require('code-generator');

const root = new Location('some/path/to/root');
const foo = createModule(root.relative('foo'));
const bar = createModule(root.relative('other/bar'));

foo.import('barvar', bar);
console.log(foo.toString()); // >> const barvar = require('./other/bar');

Adding body to the module

const { createModule, Location, Code, Var } = require('code-generator');

const root = new Location('some/path/to/root');
const foo = createModule(root.relative('foo'));
const bar = createModule(root.relative('other/bar'));

foo.import('barvar', bar);

foo.add(new Code('describe(__filename, () => {'))
        .add(`it('should do some test', () => {`)
            .add(new Var('foo', 10))
            .add(new Var('bar', false))
        .add('})')
    .add(new Code('})'))
console.log(foo.toString()); 
// >> const barvar = require('./other/bar');describe(__filename, () => {it('should do some test', () => {const foo = 10;const bar = ;})})

Pretty print

console.log(Code.pretty(foo)); 

output:

const barvar = require("./other/bar");

describe(__filename, () => {
    it("should do some test", () => {
        const foo = 10;
        const bar = false;
    });
});