Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crema

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crema - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

62

lib/index.js

@@ -1,15 +0,3 @@

//crema code here
var parser = require('./parser');
// var start = Date.now();
// var tokens = parser.parse("hello/world/gold -test=value OR -value OR -tag -method=POST google OR yahoo/taco -> (yahoo gem tacos)");
// console.log(Date.now() - start)
// console.log(JSON.stringify(tokens, null, 2));
// process.exit();
function parseTokens(route) {

@@ -52,3 +40,3 @@ return route./*route.replace(/\//g,' ').*/replace(/\s+/g,' ').split(' ');

function parseChannel(channel) {
var paths = channel instanceof Array ? channel : channel.replace(/^\/|\/$/g,'').split(/[\s\/]+/g);

@@ -60,3 +48,3 @@

var path = paths[i],
isParam = path[0] == ':'
isParam = (path.substr(0,1) == ':');

@@ -70,3 +58,3 @@ expr.paths.push({ value: isParam ? path.substr(1) : path, param: isParam });

function parseRouteChannels(rootExpr, tokens, start) {
var n = tokens.length,

@@ -132,3 +120,3 @@ currentExpression = rootExpr;

//is it a tag?
if(routeToken[0] == '-') {
if(routeToken.substr(0, 1) == '-') {

@@ -160,2 +148,42 @@ var tagParts = routeToken.split('=');

module.exports.parseChannel = parseChannel;
module.exports.parseChannel = parseChannel;
module.exports.stringifyPaths = function(paths) {
var stringified = [];
for(var i = 0, n = paths.length; i < n; i++) {
stringified.push((paths[i].param ? ':' : '') + paths[i].value);
}
return stringified.join('/');
}
module.exports.stringifyTags = function(tags) {
var stringified = [];
for(var tagName in tags) {
var tagValue = tags[tagName];
if(tagValue === true) {
stringified.push('-' + tagName);
} else {
stringified.push('-' + tagName+'='+tagValue);
}
}
return stringified.join(' ');
}
module.exports.stringify = function(route) {
var stringified = [];
if(route.type) stringified.push(route.type);
stringified.push(module.exports.stringifyTags(route.tags));
stringified.push(module.exports.stringifyPaths(route.channel.paths));
return stringified.join(' ');
}
{
"name": "crema",
"description": "syntactic sugar for your javascript functions",
"version": "0.0.4",
"version": "0.0.5",
"repository": {},

@@ -6,0 +6,0 @@ "engines": {},

Sorry, the diff of this file is not supported yet

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