From 9b3dd0125069bcbeece14e207380bcde9805ca95 Mon Sep 17 00:00:00 2001 From: Eric Ellingson Date: Wed, 24 Jan 2018 09:07:30 -0800 Subject: [PATCH] update package.json & readme --- README.md | 84 ++++++++++++++++++++++++++++++----------------- package-lock.json | 4 +-- package.json | 20 +++++------ 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index e305162..d6aeccb 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,98 @@ -# base64-img +# base64-img-promise + Convert img to base64, or convert base64 to img + ```js var base64Img = require('base64-img'); ``` + ## install + ``` npm install base64-img --save ``` + ## test + ``` mocha ``` + ## API + Note: All methods which take a callback, if omitted, will return a promise + ### .base64(filename[, callback]) + Convert image file to image base64 data -* {string} ``filename`` required -The image path -* {function} ``callback(err, data)`` optional -Callback with image base64 data + +* {string} `filename` required + The image path +* {function} `callback(err, data)` optional + Callback with image base64 data + ```js -base64Img.base64('path/demo.png', function(err, data) {}) +base64Img.base64('path/demo.png', function(err, data) {}); /* promise */ -base64Img.base64('path/demo.png').then(function(data) { - -}) +base64Img.base64('path/demo.png').then(function(data) {}); ``` ### .base64Sync(filename) -The api same as base64, but it's synchronous + +The api same as base64, but it's synchronous + ```js var data = base64Img.base64Sync('path/demo.png'); ``` ### .requestBase64(url[, callback]) -* {string} ``url`` required -* {function} ``callback(err, res, body)`` optional -Callback with http request + +* {string} `url` required +* {function} `callback(err, res, body)` optional + Callback with http request + ```js var url = 'http://../demo.png'; -base64Img.requestBase64(url, function(err, res, data) { - -}); +base64Img.requestBase64(url, function(err, res, data) {}); /* promise */ var url = 'http://../demo.png'; -base64Img.requestBase64(url).then(function({res, data}) { - -}); +base64Img.requestBase64(url).then(function({ res, data }) {}); ``` ### .img(data, destpath, name[, callback]) + Convert image base64 data to image -* {string} ``data`` required -Image base64 data -* {string} ``destpath`` required -Dest path, if the destpath is root, pass empty string -* {string} ``name`` required -The image's filename -* {function} ``callback(err, filepath)`` optional + +* {string} `data` required + Image base64 data +* {string} `destpath` required + Dest path, if the destpath is root, pass empty string +* {string} `name` required + The image's filename +* {function} `callback(err, filepath)` optional + ```js -base64Img.img('data:image/png;base64,...', 'dest', '1', function(err, filepath) {}); +base64Img.img('data:image/png;base64,...', 'dest', '1', function( + err, + filepath +) {}); /* promise */ -base64Img.img('data:image/png;base64,...', 'dest', '1').then(function(filepath) { - -}); +base64Img + .img('data:image/png;base64,...', 'dest', '1') + .then(function(filepath) {}); ``` ### .imgSync(data, destpath, name) + The api same as img, but it's synchronous + ```js var filepath = base64Img.imgSync('data:image/png;base64,...', '', '2'); -``` \ No newline at end of file +``` + +--- + +This is a fork of https://github.com/douzi8/base64-img diff --git a/package-lock.json b/package-lock.json index ebf0af2..a862b6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "base64-img", - "version": "1.0.3", + "name": "base64-img-promise", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 206bfc8..baec115 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "base64-img", - "version": "1.0.3", + "name": "base64-img-promise", + "version": "1.0.4", "description": "Convert img to base64, or convert base64 to img", "main": "base64-img.js", "scripts": { @@ -8,20 +8,16 @@ }, "repository": { "type": "git", - "url": "https://github.com/douzi8/base64-img.git" + "url": "https://github.com/e-e/base64-img-promise.git" }, - "keywords": [ - "base64", - "img", - "image", - "img base64" - ], - "author": "douzi ", + "keywords": ["base64", "img", "image", "img base64", "promise"], + "author": "Eric Ellingson ", + "original_author": "douzi ", "license": "ISC", "bugs": { - "url": "https://github.com/douzi8/base64-img/issues" + "url": "https://github.com/e-e/base64-img-promise/issues" }, - "homepage": "https://github.com/douzi8/base64-img", + "homepage": "https://github.com/e-e/base64-img-promise", "dependencies": { "ajax-request": "^1.2.0", "file-system": "^2.1.0"