New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

decypher

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decypher - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

30

decypher.js

@@ -8,3 +8,4 @@ /**

*/
var fs = require('fs');
var fs = require('fs'),
path = require('path');

@@ -71,6 +72,27 @@ // Helpers

// Main function
function decypher(spec, encoding) {
function decypher(spec, extension) {
extension = (extension || 'cypher').replace(/^\./, '');
if (typeof spec === 'string') {
return resolve(fs.readFileSync(spec, 'utf-8'), spec);
// Folder-behaviour
if (fs.lstatSync(spec).isDirectory()) {
var r = new RegExp('(.*)\\.' + extension + '$'),
o = {};
var items = fs.readdirSync(spec)
.filter(function(filename) {
return fs.lstatSync(path.join(spec, filename)).isFile() &&
~filename.search(r);
})
.forEach(function(filename) {
var p = path.join(spec, filename);
o[filename.match(r)[1]] = resolve(fs.readFileSync(p, 'utf-8'), p);
});
return o;
}
else {
return resolve(fs.readFileSync(spec, 'utf-8'), spec);
}
}

@@ -90,3 +112,3 @@ else if (isPlainObject(spec)) {

Object.defineProperty(decypher, 'version', {
value: '0.1.1'
value: '0.1.2'
});

@@ -93,0 +115,0 @@

2

package.json
{
"name": "decypher",
"version": "0.1.1",
"version": "0.1.2",
"description": "Yesql-like cypher query loader for node.js",

@@ -5,0 +5,0 @@ "main": "decypher.js",

@@ -5,5 +5,5 @@ [![Build Status](https://travis-ci.org/Yomguithereal/decypher.svg)](https://travis-ci.org/Yomguithereal/decypher)

**decypher** is a node.js library aiming at loading cypher queries from external files so you can use them later in your code.
**decypher** is a node.js library aiming at loading [cypher](http://neo4j.com/developer/cypher-query-language/) queries from external files so you can use them later in your code.
The library's philosophy is quite similar to the Clojure [Yesql](http://neo4j.com/developer/cypher-query-language/)'s one.
The library's philosophy is quite similar to the Clojure [Yesql](https://github.com/krisajenkins/yesql)'s one.

@@ -82,2 +82,20 @@ ## Installation

}
// Loading the content of a folder
// folder/
// - single.cypher
// - multiple.cypher
decypher('./folder');
>>> {
single: 'MATCH (n)-[r]-(t)\nRETURN n,r,t LIMIT 100;',
multiple: {
first: 'MATCH (b:Book)\nRETURN b;',
second: 'MATCH (v:Vocabulary)\nRETURN v;'
}
}
// Choosing a different extension when loading a folder
decypher('./path-to-queries-folder', 'cql');
```

@@ -84,0 +102,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc