Comparing version 3.0.4 to 3.0.5
28
index.js
@@ -5,3 +5,3 @@ var fs = require("fs"); | ||
function getExt(data_url){ | ||
return data_url.split("data:image/")[1].split(";")[0]; | ||
return data_url.split("data:image/")[1].split(";")[0]; | ||
} | ||
@@ -11,15 +11,11 @@ | ||
function getBa64Img(data_url){ | ||
return data_url.split(";base64,").pop(); | ||
return data_url.split(";base64,").pop(); | ||
} | ||
module.exports.fs = fs; | ||
// saves a base64 encoded image synchronously | ||
module.exports.writeImageSync = function(file_path, data_url){ | ||
if (arguments.length < 2){ | ||
throw new Error("writeImage() requires two arguments. You have only included " + arguments.length); | ||
} | ||
fs.writeFileSync(file_path + "." + getExt(data_url), getBa64Img(data_url), {encoding: "base64"}); | ||
if (arguments.length < 2){ | ||
throw new Error("writeImage() requires two arguments. You have only included " + arguments.length); | ||
} | ||
fs.writeFileSync(file_path + "." + getExt(data_url), getBa64Img(data_url), {encoding: "base64"}); | ||
} | ||
@@ -29,9 +25,6 @@ | ||
module.exports.writeImage = function(file_path, data_url, callback){ | ||
if (arguments.length < 3){ | ||
throw new Error("writeImage() requires three arguments. You have only included " + arguments.length); | ||
} | ||
fs.writeFile(file_path + "." + getExt(data_url), getBa64Img(data_url), {encoding: "base64"}, callback); | ||
if (arguments.length < 3){ | ||
throw new Error("writeImage() requires three arguments. You have only included " + arguments.length); | ||
} | ||
fs.writeFile(file_path + "." + getExt(data_url), getBa64Img(data_url), {encoding: "base64"}, callback); | ||
} | ||
@@ -41,1 +34,2 @@ | ||
module.exports.getBa64Img = getBa64Img; | ||
module.exports.fs = {readFile: fs.readFile, readFileSync: fs.readFileSync}; |
{ | ||
"name": "ba64", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "A small npm module for saving base 64 encoded images to your file system.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
5354
25