pastebin-js
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -24,2 +24,3 @@ var _ = require('underscore'), | ||
* Get a paste | ||
* @param String id Id of the paste | ||
*/ | ||
@@ -37,4 +38,4 @@ Pastebin.prototype.getPaste = function (id) { | ||
.get(getUrl, null) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
@@ -45,3 +46,8 @@ return deferred.promise; | ||
/** | ||
* Create a paste! | ||
* Create a paste | ||
* @param String text Text to be pasted | ||
* @param String title Title of the paste (optional) | ||
* @param String format Format of the paste, for syntax highlighting. See /lib/config.js (optional) | ||
* @param Number privacy Privacylevel of the paste (0 = public, 1 = unlisted and 2 = private) (optional, default = 0) | ||
* @param String expiration Expiration time of the paste See /lib/config.js | ||
*/ | ||
@@ -89,4 +95,4 @@ Pastebin.prototype.createPaste = function (text, title, format, privacy, expiration) { | ||
.createPaste(text, title, format, privacy, expiration) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}); | ||
@@ -122,3 +128,8 @@ } else { | ||
/** | ||
* Create a paste from file | ||
* Create a paste from a file | ||
* @param String filename Location of the filename | ||
* @param String title Title of the paste (optional) | ||
* @param String format Format of the paste, for syntax highlighting. See /lib/config.js (optional) | ||
* @param Number privacy Privacylevel of the paste (0 = public, 1 = unlisted and 2 = private) (optional, default = 0) | ||
* @param String expiration Expiration time of the paste See /lib/config.js | ||
*/ | ||
@@ -140,4 +151,4 @@ Pastebin.prototype.createPasteFromFile = function (filename, title, format, privacy, expiration) { | ||
.createPaste(data, title, format, privacy, expiration) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
@@ -150,12 +161,42 @@ }); | ||
/** | ||
* Delete a paste created by user | ||
* NOT YET IMPLEMENTED | ||
* Delete a paste that is created by the user | ||
* @param String pasteID The id of the userpaste (http://pastebin.com/[id]) | ||
*/ | ||
Pastebin.prototype.deletePaste = function () { | ||
Pastebin.prototype.deletePaste = function (pasteID) { | ||
var _this = this, | ||
p = {}, | ||
deferred = Q.defer(); | ||
// To be implemented | ||
deferred.resolve(true); | ||
if (!pasteID) { | ||
deferred.reject(new Error("Please provide a paste ID to delete")); | ||
} | ||
p.api_option = 'delete'; | ||
p.api_dev_key = _this.config.api_dev_key; | ||
p.api_paste_key = pasteID; | ||
if (_this.config.api_user_key) { | ||
p.api_user_key = _this.config.api_user_key; | ||
_this | ||
._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.post, p) | ||
.then(function (data) { | ||
deferred.resolve(data); | ||
}) | ||
.fail(deferred.reject); | ||
} else if (_this.config.api_user_name !== null && _this.config.api_user_password !== null) { | ||
_this | ||
.createAPIuserKey() | ||
.then(function () { | ||
_this | ||
.deletePaste(pasteID) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}); | ||
} else { | ||
deferred.reject(new Error("Error! Deleting a paste created by the user needs username and password")); | ||
} | ||
return deferred.promise; | ||
@@ -192,3 +233,4 @@ }; | ||
/** | ||
* Lists the user pastes | ||
* List the pastes that are created by the user | ||
* @param Number limit Set the limit of pastes | ||
*/ | ||
@@ -205,8 +247,9 @@ Pastebin.prototype.listUserPastes = function (limit) { | ||
.createAPIuserKey() | ||
.then(function () { | ||
_this | ||
.listUserPastes(limit) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}); | ||
.then(function () { | ||
_this | ||
.listUserPastes(limit) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}) | ||
.fail(deferred.reject); | ||
@@ -225,4 +268,4 @@ } else { | ||
._parsePastes(data) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}) | ||
@@ -248,9 +291,9 @@ .fail(deferred.reject); | ||
._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.post, params) | ||
.then(function (data) { | ||
_this | ||
._parsePastes(data) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}) | ||
.fail(deferred.reject); | ||
.then(function (data) { | ||
_this | ||
._parsePastes(data) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}) | ||
.fail(deferred.reject); | ||
@@ -274,8 +317,9 @@ return deferred.promise; | ||
.createAPIuserKey() | ||
.then(function () { | ||
_this | ||
.getUserInfo() | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}); | ||
.then(function () { | ||
_this | ||
.getUserInfo() | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
}) | ||
.fail(deferred.reject); | ||
} else { | ||
@@ -411,4 +455,4 @@ params.api_user_key = _this.config.api_user_key; | ||
.get(path, params) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
@@ -426,4 +470,4 @@ return deferred.promise; | ||
.post(path, params) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
@@ -430,0 +474,0 @@ return deferred.promise; |
@@ -0,6 +1,14 @@ | ||
0.1.5 / 2014-04-06 | ||
================== | ||
* Finishing deletePaste | ||
* Adding more descriptive comments for methods, needs more work in the future | ||
0.1.4 / 2014-04-06 | ||
================== | ||
* Attempt to fix issue installing pastebin-js | ||
* Attempt to fix issue installing pastebin-js, pushed to new version | ||
0.1.3 / 2013-11-29 | ||
================== | ||
@@ -7,0 +15,0 @@ * Added documentation! |
{ | ||
"name": "pastebin-js", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "NodeJS module for Pastebin API", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -21,2 +21,3 @@ pastebin-js | ||
* createPasteFromFile : read a file (UTF8) and paste it | ||
* deletePaste : delete a paste created by the user | ||
@@ -103,3 +104,3 @@ ## Example | ||
**pastebin.deletePaste()** : NOT YET IMPLEMENTED! (Will be in future version) | ||
**pastebin.deletePaste(pasteID)** : Tries to delete a paste, created by the user | ||
@@ -106,0 +107,0 @@ **pastebin.getUserInfo()** : gets the userinfo |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
773
140
0
33605
10