convert-source-map
Advanced tools
Comparing version 1.8.0 to 1.9.0
55
index.js
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var SafeBuffer = require('safe-buffer'); | ||
@@ -19,7 +18,28 @@ Object.defineProperty(exports, 'commentRegex', { | ||
var decodeBase64; | ||
if (typeof Buffer !== 'undefined') { | ||
if (typeof Buffer.from === 'function') { | ||
decodeBase64 = decodeBase64WithBufferFrom; | ||
} else { | ||
decodeBase64 = decodeBase64WithNewBuffer; | ||
} | ||
} else { | ||
decodeBase64 = decodeBase64WithAtob; | ||
} | ||
function decodeBase64(base64) { | ||
return (SafeBuffer.Buffer.from(base64, 'base64') || "").toString(); | ||
function decodeBase64WithBufferFrom(base64) { | ||
return Buffer.from(base64, 'base64').toString(); | ||
} | ||
function decodeBase64WithNewBuffer(base64) { | ||
if (typeof value === 'number') { | ||
throw new TypeError('The value to decode must not be of type number.'); | ||
} | ||
return new Buffer(base64, 'base64').toString(); | ||
} | ||
function decodeBase64WithAtob(base64) { | ||
return decodeURIComponent(escape(atob(base64))); | ||
} | ||
function stripComment(sm) { | ||
@@ -60,7 +80,30 @@ return sm.split(',').pop(); | ||
Converter.prototype.toBase64 = function () { | ||
if (typeof Buffer !== 'undefined') { | ||
if (typeof Buffer.from === 'function') { | ||
Converter.prototype.toBase64 = encodeBase64WithBufferFrom; | ||
} else { | ||
Converter.prototype.toBase64 = encodeBase64WithNewBuffer; | ||
} | ||
} else { | ||
Converter.prototype.toBase64 = encodeBase64WithBtoa; | ||
} | ||
function encodeBase64WithBufferFrom() { | ||
var json = this.toJSON(); | ||
return (SafeBuffer.Buffer.from(json, 'utf8') || "").toString('base64'); | ||
}; | ||
return Buffer.from(json, 'utf8').toString('base64'); | ||
} | ||
function encodeBase64WithNewBuffer() { | ||
var json = this.toJSON(); | ||
if (typeof json === 'number') { | ||
throw new TypeError('The json to encode must not be of type number.'); | ||
} | ||
return new Buffer(json, 'utf8').toString('base64'); | ||
} | ||
function encodeBase64WithBtoa() { | ||
var json = this.toJSON(); | ||
return btoa(unescape(encodeURIComponent(json))); | ||
} | ||
Converter.prototype.toComment = function (options) { | ||
@@ -67,0 +110,0 @@ var base64 = this.toBase64(); |
{ | ||
"name": "convert-source-map", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Converts a source-map from/to different formats and allows adding/changing properties.", | ||
@@ -14,5 +14,2 @@ "main": "index.js", | ||
"homepage": "https://github.com/thlorenz/convert-source-map", | ||
"dependencies": { | ||
"safe-buffer": "~5.1.1" | ||
}, | ||
"devDependencies": { | ||
@@ -19,0 +16,0 @@ "inline-source-map": "~0.6.2", |
@@ -1,2 +0,2 @@ | ||
# convert-source-map [![build status](https://secure.travis-ci.org/thlorenz/convert-source-map.svg?branch=master)](http://travis-ci.org/thlorenz/convert-source-map) | ||
# convert-source-map [![Build Status][ci-image]][ci-url] | ||
@@ -121,1 +121,4 @@ Converts a source-map from/to different formats and allows adding/changing properties. | ||
When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file. | ||
[ci-url]: https://github.com/thlorenz/convert-source-map/actions?query=workflow:ci | ||
[ci-image]: https://img.shields.io/github/workflow/status/thlorenz/convert-source-map/CI?style=flat-square |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11434
0
144
124
- Removedsafe-buffer@~5.1.1
- Removedsafe-buffer@5.1.2(transitive)