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

react-server-module-tagger

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-server-module-tagger - npm Package Compare versions

Comparing version 0.4.10 to 0.6.0

68

index.js
var isWindows = ('win32' === process.platform);
/**
* A util function for tagging modules.
* @example
* tagger({filePath: '/path/to/my/file.js', trim: 'path.to.', optString: '({label: "foo"})')
* // returns '{\"label\":\"foo\",\"name\":\"my.file\",\"color\":{\"server\":87,\"client\":\"rgb(42,212,212)\"}}'
* @param {String} filePath The path to the file
* @param {String} optString The label to add to the module tag, in the form '({label:"$label"})'
* @param {String} trim The prefix to remove from the logger name
* @param {String} basePath The path to the root of the project
* @param {String} prefix A prefix to prepend to the logger name
* @return {String} A json object containing a module identifier
*/
module.exports = function(arg){
var optString = arg.optString
, fn = arg.filePath
, trim = arg.trim || ''
, basePath = arg.basePath || ''
, prefix = arg.prefix
, opts = {}
if (fn.indexOf(basePath) !== 0) {
throw new Error("Unable to handle " + basePath + " for " + fn);
}
if (optString) {
// The slash replacement here is so we don't choke on example
// loggers in comments.
opts = new Function("return "+optString.replace(/^\/\//mg,''))(); // eslint-disable-line no-new-func
}
opts.name = getName (fn, opts, trim, basePath, prefix);
opts.color = getColor (opts);
return JSON.stringify(opts);
}
/**
* Gets the name of a logger from its filepath.

@@ -112,3 +76,3 @@ * @example

var hash = 0, i, chr, len;
if (str.length === 0) return hash;
if (!str || str.length === 0) return hash;
for (i = 0, len = str.length; i < len; i++) {

@@ -130,1 +94,31 @@ chr = str.charCodeAt(i);

})();
/**
* A util function for tagging modules.
* @example
* tagger({filePath: '/path/to/my/file.js', trim: 'path.to.', opts: {label: "foo"})
* // returns '{\"label\":\"foo\",\"name\":\"my.file\",\"color\":{\"server\":87,\"client\":\"rgb(42,212,212)\"}}'
* @param {String} filePath The path to the file
* @param {String} opts The options, including a label, to add to the module tag
* @param {String} trim The prefix to remove from the logger name
* @param {String} basePath The path to the root of the project
* @param {String} prefix A prefix to prepend to the logger name
* @return {String} A json object containing a module identifier
*/
module.exports = function(arg){
var opts = arg.opts || {}
, fn = arg.filePath
, trim = arg.trim || ''
, basePath = arg.basePath || ''
, prefix = arg.prefix
if (fn.indexOf(basePath) !== 0) {
throw new Error("Unable to handle " + basePath + " for " + fn);
}
opts.name = getName (fn, opts, trim, basePath, prefix);
opts.color = getColor (opts);
return JSON.stringify(opts);
}
{
"name": "react-server-module-tagger",
"version": "0.4.10",
"version": "0.6.0",
"description": "calculates module level config",

@@ -25,8 +25,9 @@ "main": "index.js",

"devDependencies": {
"ava": "^0.16.0",
"ava": "^0.17.0",
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"del-cli": "^0.2.0"
"del-cli": "^0.2.0",
"eslint": "^3.8.1"
}
}

@@ -18,4 +18,4 @@ # react-server-module-tagger

const filePath = 'path/to/my/output.js';
const optString = '({label:"foo"})'
const moduleTag = tagger({ filePath, trim: 'path/to', optString });
const opts = {label:"foo"};
const moduleTag = tagger({ filePath, trim: 'path/to', opts });
```

@@ -22,0 +22,0 @@

@@ -37,6 +37,6 @@ import test from 'ava';

const filePath = 'has/label';
const optString = '({label: "foo"})';
const actual = loggerSpec({filePath, optString});
const opts = {label: "foo"};
const actual = loggerSpec({filePath, opts});
t.is(expected, actual);
});
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