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

jsccon

v1.0.1

Published

Json? come on, try jscon for more ✨ enhanced ✨ files.

Downloads

3

Readme

JSON? Come on.. JSCON is more ✨ ENHANCED ✨

JSCON is a Node.js library for working with JSON and JSCON files. It provides methods for parsing, writing, and sorting files, as well as other cool features!

Installation

To install JSCON, use the following command, make sure it is spelled jsccon JSCCON NOT JSCON:

npm install jsccon

API

  • parse(file) - Read .jscon file and convert to JavaScript object, the file is an jscon file, should look like <filename>.jscon
  • sort(<file or url>, {by: "less|more", proprety: "<number property>", arrayProprety: "<array property>", output: "filename.jscon|object"}) Sort by property number or array values length where property is a number property and arrayProperty is an property that own array
  • merge(outputFileName, [files]) Merge multiple files into one file, where outputFileName is the output file name, and [files] is array of file names
  • set(file, newData) Set a new object to the file, newData is object
  • delete(file, {property: "property_name", value: "value"}) Delete an item from the file.
  • update(file, {property: "property_name", value: "value", newData: {age: "18", job: "Playing video games all night"}}) Update the data who has the same property and value with and add the newData.

Code sample:

Now. Let's say that's your json file:

[
  {
    "id": 1,
    "name": "Alice",
    "age": 25,
    "pets": [
      {
        "name": "Fluffy",
        "type": "cat"
      },
      {
        "name": "Rover",
        "type": "dog"
      }
    ]
  },
  {
    "id": 2,
    "name": "Bob",
    "age": 30,
    "pets": [
      {
        "name": "Spot",
        "type": "dog"
      }
    ]
  },
  {
    "id": 3,
    "name": "Charlie",
    "age": 20,
    "pets": []
  }
]

And that's how to use JSCON various functions to sort this JSON file:

Read & Transfer .JSCON file to JS object:

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Parse a JSCON file
const data = jscon.parse('example.jscon');
console.log(data);

Sort a .JSCON file by less & more:

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Sort a .JSCON file by less
jscon.sort('example.jscon', { by: 'less', property: 'age', output: 'sorted_data.jscon' });

// Sort a .JSCON file by more
jscon.sort('example.jscon', { by: 'more', property: 'age', output: 'sorted_data.jscon' });

// Sort a .JSCON file by less values in array
jscon.sort('example.jscon', { by: 'less', arrayProperty: 'pets', output: 'sorted_data.jscon' });

// Sort a .JSCON file by more values in array
jscon.sort('example.jscon', { by: 'more', arrayProperty: 'age', output: 'sorted_data.jscon' });

// Sort a .JSCON file by less, but return data as object
jscon.sort('example.jscon', { by: 'less', property: 'age', output: 'object' });

Merge multiple .JSCON files

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Merge multiple JSCON files
const inputFiles = ['file1.jscon', 'file2.jscon'];
jscon.merge('merged_data.jscon', inputFiles);

Delete an item from a JSCON file:

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Delete an item from a JSON file
jscon.delete('example.jscon', { property: 'name', value: 'Alice' });

Add an item to JSCON file

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Add an item to a JSCON file
const newData = { name: 'Sarah', age: 28, pets: [] };
jscon.set('example.jscon', newData);

Update an item in a .JSCON file:

// Require the library 
const JSCON = require('jsccon');
const jscon = new JSCON();

// Update an item in a JSCON file
const updatedData = { age: 26 };
jscon.update('example.json', { property: 'name', value: 'Bob', newData: updatedData });

License

JSCON is released under the MIT License. Read more

Contribution:

Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue on the GitHub repository, also be free to send important bugs to my email adress

Credits

Credits goes to abdlmutii, if you like this npm package please remember to check other work i've done on github and star this repo.