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

jsucc

v1.0.0

Published

Allows conversion from JSON to SUCC.

Downloads

7

Readme

jSUCC

jSUCC is a node module to use the SUCC (Sexy and Utilitarian Code Configuration) file format created by Jimmy Cushnie


Do your configuration files look like this?

<weapons>
    <weapon>
        <name>sword</name>
        <damage>10</damage>
        <attackSpeed>1</attackSpeed>
    </weapon>
    <weapon>
        <name>dagger</name>
        <damage>6</damage>
        <attackSpeed>1.3</attackSpeed>
    </weapon>
    <weapon>
        <name>axe</name>
        <damage>20</damage>
        <attackSpeed>0.4</attackSpeed>
    </weapon>
</weapons>

Do your configuration files, god forbid, look like this? cough cougheasy save

{"weapons":{"__type":"System.Collections.Generic.List`1[[Weapon, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]],mscorlib","value":[{"name":"sword","damage":10,"attackSpeed":1},{"name":"dagger","damage":6,"attackSpeed":1.3},{"name":"axe","damage":20,"attackSpeed":0.4}]}}

With SUCC, your configuration files can look like this:

weapons:
    -
        name: sword
        damage: 10
        attackSpeed: 1
    -
        name: dagger
        damage: 6
        attackSpeed: 1.3
    -
        name: axe
        damage: 20
        attackSpeed: 0.4

Look at that. That's a beautiful configuration file. There's zero wasted space on formatting. Everything is laid out clearly so that it's easy to find what you're looking for. The file is fast for a human to read and fast for a human to edit. If you were working on this game and needed to add a new weapon type, what would you rather the configuration file look like?

Furthermore, SUCC gives you a lot of freedom when writing or editing config files. You can play around with the colon position and the indentation level, you can add whitespace, you can add comments. The following file will, to SUCC, load exactly the same as the preceding one:

weapons:
    - # the sword is your starting weapon, very general purpose.
        name : sword
        damage : 10
        attackSpeed : 1
      
    - # daggers are useful against enemies with slow attack rates.
        name : dagger
        damage : 6
        attackSpeed : 1.3
      
    -
    # you use an axe when you need to get rid of a low-health
    # enemy as quickly as possible.
        name : axe
        damage : 20 # this is overpowered. TODO balance better
        attackSpeed : 0.4

Not only are SUCC files easy to work with in a text editor, they're easy to work with in your code too. Here is all the code required to recreate that configuration file:

const { DataFiles } = require("jsucc");

class Program
{
    static Main()
    {
        this.weapons = {
            {
                name : "sword",
                damage : 10,
                attackSpeed : 1
            },
            {
                name : "dagger",
                damage : 6,
                attackSpeed : 1.3
            },
            {
                name : "axe",
                damage : 20,
                attackSpeed : 0.4
            }
        };

        var file = new DataFile("weaponsFile");
        file.Set("weapons", weapons);
    }
}

The important part of that is

var file = new DataFile("weaponsFile");
file.Set("weapons", weapons);

You keep a reference to that DataFile variable, and later when you need to read it, it's as simple as this:

var weaponsList = file.Get("weapons");

But it can be even easier. You just do

var weaponsList = file.Get("weapons", {name:"fists", damage:1, attackSpeed:1.8});

SUCC will check if a value called "weapons" exists in the file. If so, it will read the file and give you that data. If not, it will save defaultValue to the file and return it to you.

Start Using SUCC

Much more information about SUCC can be found on the wiki. If you're new to SUCC, you probably want to see the Installing and Getting Started[1] pages.

discprenency

1. The wiki page linked refers to code in C#.