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

cryostore

v0.0.8

Published

Turns your javascript code into JSON and stores it.

Downloads

9

Readme

Cryostore - Converts Javascript into Frozen JSON scripts :snowflake:

NPM

This module takes your Javascript code and turns it into a JSON object. Insecure? Probably. Fun? Yes.

Installation:

npm install cryostore 	 // - your project directory, this is just for using javascript functions in your code - // 
npm install -g cryostore // - to use the global utility on the command line - //

It's very important to note that any time you use the command line, you are using the globally installed module and any frozen or unfrozen files will be located inside /usr/local/lib/node_modules/cryostore/icebox/frozen (or unfrozen) on a mac or unix based system (On windows idk, good luck you're on your own).

Anytime you use the in-code methods like cryo.importJS(......) this will affect the locally installed copy in your current project.

Usage (code):


var cryo = require('cryostore')

// - imports a file from an arbitrary path into cryostore - //
// - imported JSON files should be files produced by cryostore - //

cryo.import('../arbitrary/path/to/jsorjson/file', function(trueorfalse){
 	if(trueorfalse === true){console.log('successful import!')}
	else{console.log('unsuccessful import :(')}
})

// - takes a .js file and turns into JSON - //
cryo.freeze('jsfile', function(success){
	console.log(success)
})

// - takes a .json file and turns into .js - //
cryo.unfreeze('jsonfile', function(success){
	console.log(success)
}) 

// - pulls out and returns data from a js (unfrozen) or json (frozen) file  - //
cryo.excavate('file', function(jsondata){
	for (var key in jsondata){
		console.log(jsondata[key])
	}
})

// - removes a file by name from frozen or unfrozen - //
cryo.remove('file',function(trueorfalse){

	if(trueorfalse === true){console.log('successful remove!')}
	else{console.log('unsuccessful remove :(')}
})

//- removes all files from the unfrozen (js) folder - //
cryo.removeall(function(trueorfalse){

},'js')//can replace 'js' with 'json' or leave the parameter empty entirely to clear all folders. 

Usage (terminal):


cryostore ls           	      // lists frozen and unfrozen files
cryostore list 

cryostore f test.js          // freezes that file, js -> json
cryostore freeze test.js

cryostore u test.js          // unfreezes that json file, json -> js
cryostore unfreeze test.js

cryostore x test.json        // prints file data in the console
cryostore x test.js 
cryostore excavate test.json
cryostore excavate test.js 

cryostore i path/to/from/current/test.json // imports an existing file from somewhere into frozen/unfrozen 
cryostore i path/to/from/current/test.js
cryostore import path/to/from/current/test.js

cryostore r test.js 
cryostore r test.json
cryostore remove test.js     // removes a single file, test.js, from unfrozen
cryostore remove test.json   // removes a singel file, test.json, from frozen

cryostore removeall          // clears your icebox (frozen and unfrozen folders)
cryostore removeall js       // clears only your unfrozen (the one with the js files) folder
cryostore removeall json     // clears only your frozen (the one with the json files)folder

NOTE: All uses of 'cryostore' can be replaced with shorthand 'cryo'.

Icebox:

Contains frozen and unfrozen folders. Frozen is the place where JS gets stored as JSON. Contains .frozen.json file, don't overwrite it. Unfrozen is the place where your frozen JSON gets stored as JS. Contains .unfrozen.json file, don't overwrite it.

Example using async:

Since node is asynchronous we can't just call:


var cryo = require('cryostore')

cryo.import('../dummycontainer/jsfile', function(trueorfalse){

 	if(trueorfalse === true){callback(null, 'successful import')}
	else{callback(null, 'failed import')}
})

// - takes a .js file and turns into JSON - //
cryo.freeze('jsfile', function(success){

	console.log(success)
})

in succession. We could put the cryo.freeze call inside cryo.importJS callback, but this puts us in dangerous territory and can land us in callback hell.

Using async we can combine asynchronous funtions to only execute after the predecessors are done. Like so:

var cryo = require('cryostore')
var async = require('async')

async.series([

	function(callback){
		
		cryo.import('arbitrary/path/to/jsfile', function(trueorfalse){

 			if(trueorfalse === true){callback(null, 'successful import')}
			else{callback(null, 'failed import')}
		})
	},

	function(callback){

		cryo.freeze('jsfile', function(success){
			
			callback(null, success)
		})
	}
], function(err, results){
	
	// results is an array that where the first element is 'sucessful import'
	// or failed import depending on the first function in series, and whether
	// the import was successful
	// the second element will be true or false depending on whether the freezing was successful
	console.log(results)
})

you should npm install async as well as add it to your package.json under dependencies to use the package, it's not included with standard node.js.

Todo:

Could eventually also work with mongoDB, could be cool.

Check to make sure we're not over writing files, add - number indexes onto repeat files.

Support Javascript objects.

Add the ability to create modular divisions within code.

Hit me up on twitter at @yvanscher.