Socket
Socket
Sign inDemoInstall

inline-source-map

Package Overview
Dependencies
2
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.2.0

test/source-content.js

35

index.js

@@ -18,2 +18,3 @@ 'use strict';

this.generator = new SourceMapGenerator({ file: opts.file || '', sourceRoot: opts.sourceRoot || '' });
this.sourceContent = undefined;
}

@@ -70,2 +71,17 @@

/**
* Adds source content for the given source file.
*
* @name addSourceContent
* @function
* @param sourceFile {String} The source file for which a mapping is included
* @param sourceContent {String} The content of the source file
* @return {Object} The generator to allow chaining
*/
Generator.prototype.addSourceContent = function (sourceFile, sourceContent) {
this.sourceContent = this.sourceContent || {};
this.sourceContent[sourceFile] = sourceContent;
return this;
};
/**
* @name base64Encode

@@ -76,3 +92,3 @@ * @function

Generator.prototype.base64Encode = function () {
var map = this.generator.toString();
var map = this.toString();
return new Buffer(map).toString('base64');

@@ -90,2 +106,15 @@ };

Generator.prototype.toJSON = function () {
var map = this.generator.toJSON();
if (!this.sourceContent) return map;
var toSourceContent = (function (s) { return this.sourceContent[s] || null; }).bind(this);
map.sourceContent = map.sources.map(toSourceContent);
return map;
};
Generator.prototype.toString = function () {
return JSON.stringify(this);
};
Generator.prototype._mappings = function () {

@@ -95,3 +124,7 @@ return this.generator._mappings;

Generator.prototype.gen = function () {
return this.generator;
};
module.exports = function (opts) { return new Generator(opts); };
module.exports.Generator = Generator;

4

package.json
{
"name": "inline-source-map",
"version": "0.1.3",
"version": "0.2.0",
"description": "Adds source mappings and base64 encodes them, so they can be inlined in your generated file.",
"main": "inline-source-map.js",
"scripts": {
"test": "node-trap test/*.js"
"test": "node-trap ./test/*.js && node-trap test/source-content.js"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -53,2 +53,17 @@ # inline-source-map [![build status](https://secure.travis-ci.org/thlorenz/inline-source-map.png)](http://travis-ci.org/thlorenz/inline-source-map)

### addSourceContent(sourceFile, sourceContent)
```
/**
* Adds source content for the given source file.
*
* @name addSourceContent
* @function
* @param sourceFile {String} The source file for which a mapping is included
* @param sourceContent {String} The content of the source file
* @return {Object} The generator to allow chaining
*/
```
### base64Encode()

@@ -64,2 +79,4 @@

If source contents were added, this will be included in the encoded mappings.
### inlineMappingUrl()

@@ -66,0 +83,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc