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

broccoli-json-global

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-json-global - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

11

index.js

@@ -15,2 +15,3 @@ var Filter = require('broccoli-filter');

this.globalName = options.globalName || 'JSON_DATA';
this.nestData = options.nestData;
}

@@ -20,4 +21,10 @@

JSONFilter.prototype.targetExtension = 'js';
JSONFilter.prototype.processString = function(string) {
return 'var ' + this.globalName + ' = ' + string + ';';
JSONFilter.prototype.processString = function(string, relativePath) {
var varName = 'window.' + this.globalName;
var initializer = '';
if (this.nestData) {
initializer = varName + ' = ' + varName + ' || {}; ';
varName += '[\'' + relativePath.replace(/.json$/, '') + '\']';
}
return initializer + varName + ' = ' + string + ';';
}

2

package.json
{
"name": "broccoli-json-global",
"version": "0.0.2",
"version": "0.0.3",
"description": "Takes a JSON tree and converts it to a .js file that exposes it globally.",

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

@@ -14,4 +14,11 @@ # broccoli-json-global

var tree = broccoli.makeTree('public/data');
tree = jsonGlobal(tree);
tree = jsonGlobal('public/data', {
// The name of your globals object. Default is JSON_DATA.
globalName: 'GLOBALS',
// Whether or not to nest data. Keys will be the file name. Default is false.
nestData: true
});
```
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