Socket
Socket
Sign inDemoInstall

snoowrap

Package Overview
Dependencies
57
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.18.0 to 1.19.0

dist/objects/Comment.d.ts

6

CHANGELOG.md
# Changelog
## v1.19.0 (2019-08-05)
* Added TypeScript definitions
* Added `Subreddit#getNewModmailConversations`
* Added `snoowrap#getContentByIds`
## v1.18.0 (2019-07-23)

@@ -4,0 +10,0 @@

52

dist/constants.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", {

});
var MODULE_NAME = exports.MODULE_NAME = 'snoowrap';
var VERSION = exports.VERSION = '1.18.0';
var DOCS_LINK = exports.DOCS_LINK = 'https://not-an-aardvark.github.io/snoowrap/';
var API_RULES_LINK = exports.API_RULES_LINK = 'https://github.com/reddit/reddit/wiki/API';
exports.MAX_LISTING_ITEMS = exports.MAX_API_MORECHILDREN_AMOUNT = exports.MAX_API_INFO_AMOUNT = exports.MAX_TOKEN_LATENCY = exports.IDEMPOTENT_HTTP_VERBS = exports.HTTP_VERBS = exports.LIVETHREAD_PERMISSIONS = exports.MODERATOR_PERMISSIONS = exports.USERNAME_REGEX = exports.KINDS = exports.SUBREDDIT_KEYS = exports.USER_KEYS = exports.API_RULES_LINK = exports.DOCS_LINK = exports.VERSION = exports.MODULE_NAME = void 0;
var MODULE_NAME = 'snoowrap';
exports.MODULE_NAME = MODULE_NAME;
var VERSION = '1.19.0';
exports.VERSION = VERSION;
var DOCS_LINK = 'https://not-an-aardvark.github.io/snoowrap/';
exports.DOCS_LINK = DOCS_LINK;
var API_RULES_LINK = 'https://github.com/reddit/reddit/wiki/API';
/* USER_KEYS and SUBREDDIT_KEYS are keys that are replaced by RedditUser and Subreddit objects when encountered in

@@ -15,5 +19,9 @@ `snoowrap#_populate`. `author`, `approved_by`, `banned_by`, and `subreddit` all appear in fetched Submissions, among other

endpoint. */
var USER_KEYS = exports.USER_KEYS = new Set(['author', 'approved_by', 'banned_by', 'user']);
var SUBREDDIT_KEYS = exports.SUBREDDIT_KEYS = new Set(['subreddit', 'sr']);
var KINDS = exports.KINDS = {
exports.API_RULES_LINK = API_RULES_LINK;
var USER_KEYS = new Set(['author', 'approved_by', 'banned_by', 'user']);
exports.USER_KEYS = USER_KEYS;
var SUBREDDIT_KEYS = new Set(['subreddit', 'sr']);
exports.SUBREDDIT_KEYS = SUBREDDIT_KEYS;
var KINDS = {
t1: 'Comment',

@@ -42,10 +50,20 @@ t2: 'RedditUser',

};
var USERNAME_REGEX = exports.USERNAME_REGEX = /^[\w-]{1,20}$/;
var MODERATOR_PERMISSIONS = exports.MODERATOR_PERMISSIONS = ['wiki', 'posts', 'access', 'mail', 'config', 'flair'];
var LIVETHREAD_PERMISSIONS = exports.LIVETHREAD_PERMISSIONS = ['update', 'edit', 'manage'];
var HTTP_VERBS = exports.HTTP_VERBS = ['delete', 'get', 'head', 'patch', 'post', 'put'];
var IDEMPOTENT_HTTP_VERBS = exports.IDEMPOTENT_HTTP_VERBS = ['delete', 'get', 'head', 'put'];
var MAX_TOKEN_LATENCY = exports.MAX_TOKEN_LATENCY = 10000;
var MAX_API_INFO_AMOUNT = exports.MAX_API_INFO_AMOUNT = 100;
var MAX_API_MORECHILDREN_AMOUNT = exports.MAX_API_MORECHILDREN_AMOUNT = 20;
var MAX_LISTING_ITEMS = exports.MAX_LISTING_ITEMS = 100;
exports.KINDS = KINDS;
var USERNAME_REGEX = /^[\w-]{1,20}$/;
exports.USERNAME_REGEX = USERNAME_REGEX;
var MODERATOR_PERMISSIONS = ['wiki', 'posts', 'access', 'mail', 'config', 'flair'];
exports.MODERATOR_PERMISSIONS = MODERATOR_PERMISSIONS;
var LIVETHREAD_PERMISSIONS = ['update', 'edit', 'manage'];
exports.LIVETHREAD_PERMISSIONS = LIVETHREAD_PERMISSIONS;
var HTTP_VERBS = ['delete', 'get', 'head', 'patch', 'post', 'put'];
exports.HTTP_VERBS = HTTP_VERBS;
var IDEMPOTENT_HTTP_VERBS = ['delete', 'get', 'head', 'put'];
exports.IDEMPOTENT_HTTP_VERBS = IDEMPOTENT_HTTP_VERBS;
var MAX_TOKEN_LATENCY = 10000;
exports.MAX_TOKEN_LATENCY = MAX_TOKEN_LATENCY;
var MAX_API_INFO_AMOUNT = 100;
exports.MAX_API_INFO_AMOUNT = MAX_API_INFO_AMOUNT;
var MAX_API_MORECHILDREN_AMOUNT = 20;
exports.MAX_API_MORECHILDREN_AMOUNT = MAX_API_MORECHILDREN_AMOUNT;
var MAX_LISTING_ITEMS = 100;
exports.MAX_LISTING_ITEMS = MAX_LISTING_ITEMS;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,4 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = _default;
exports.default = function () {
var _helpers = require("./helpers.js");
function _default() {
var config = Object.create(null);

@@ -19,6 +22,3 @@ config.endpointDomain = 'reddit.com';

config.proxies = true;
return (0, _helpers.addSnakeCaseShadowProps)(config);
};
var _helpers = require('./helpers.js');
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", {

});
exports.StatusCodeError = exports.RequestError = exports.InvalidMethodCallError = exports.NoCredentialsError = exports.InvalidUserError = exports.RateLimitError = undefined;
exports.rateLimitWarning = rateLimitWarning;
exports.StatusCodeError = exports.RequestError = exports.InvalidMethodCallError = exports.NoCredentialsError = exports.InvalidUserError = exports.RateLimitError = void 0;
var _constants = require('./constants.js');
var _constants = require("./constants.js");
/* eslint-disable max-len */
class RateLimitError extends Error {
constructor() {
super(_constants.MODULE_NAME + ' refused to continue because reddit\'s ratelimit was exceeded. For more information about reddit\'s ratelimit, please consult reddit\'s API rules at ' + _constants.API_RULES_LINK + '.');
super("".concat(_constants.MODULE_NAME, " refused to continue because reddit's ratelimit was exceeded. For more information about reddit's ratelimit, please consult reddit's API rules at ").concat(_constants.API_RULES_LINK, "."));
}
}
exports.RateLimitError = RateLimitError; /* eslint-disable max-len */
exports.RateLimitError = RateLimitError;

@@ -23,26 +25,33 @@ class InvalidUserError extends Error {

var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Cannot fetch information on the given user. Please be sure you have the right username.';
super(message);
}
}
exports.InvalidUserError = InvalidUserError;
class NoCredentialsError extends Error {
constructor() {
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Missing credentials passed to ' + _constants.MODULE_NAME + ' constructor. You must pass an object containing either (a) userAgent, clientId, clientSecret, and refreshToken properties, (b) userAgent and accessToken properties, or (c) userAgent, clientId, clientSecret, username, and password properties. For information, please read the docs at ' + _constants.DOCS_LINK + '.';
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Missing credentials passed to ".concat(_constants.MODULE_NAME, " constructor. You must pass an object containing either (a) userAgent, clientId, clientSecret, and refreshToken properties, (b) userAgent and accessToken properties, or (c) userAgent, clientId, clientSecret, username, and password properties. For information, please read the docs at ").concat(_constants.DOCS_LINK, ".");
super(message);
}
}
exports.NoCredentialsError = NoCredentialsError;
class InvalidMethodCallError extends Error {}
exports.InvalidMethodCallError = InvalidMethodCallError;
class RequestError extends Error {}
exports.RequestError = RequestError;
class StatusCodeError extends Error {}
exports.StatusCodeError = StatusCodeError;
function rateLimitWarning(millisecondsUntilReset) {
return 'Warning: ' + _constants.MODULE_NAME + ' temporarily stopped sending requests because reddit\'s ratelimit was exceeded. The request you attempted to send was queued, and will be sent to reddit when the current ratelimit period expires in ' + millisecondsUntilReset / 1000 + ' seconds.';
return "Warning: ".concat(_constants.MODULE_NAME, " temporarily stopped sending requests because reddit's ratelimit was exceeded. The request you attempted to send was queued, and will be sent to reddit when the current ratelimit period expires in ").concat(millisecondsUntilReset / 1000, " seconds.");
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,42 +6,2 @@ Object.defineProperty(exports, "__esModule", {

});
exports.isBrowser = exports.formatLivethreadPermissions = exports.formatModPermissions = undefined;
var _snakeCase2 = require('lodash/snakeCase');
var _snakeCase3 = _interopRequireDefault(_snakeCase2);
var _remove2 = require('lodash/remove');
var _remove3 = _interopRequireDefault(_remove2);
var _property2 = require('lodash/property');
var _property3 = _interopRequireDefault(_property2);
var _partial2 = require('lodash/partial');
var _partial3 = _interopRequireDefault(_partial2);
var _omit2 = require('lodash/omit');
var _omit3 = _interopRequireDefault(_omit2);
var _keyBy2 = require('lodash/keyBy');
var _keyBy3 = _interopRequireDefault(_keyBy2);
var _isEmpty2 = require('lodash/isEmpty');
var _isEmpty3 = _interopRequireDefault(_isEmpty2);
var _includes2 = require('lodash/includes');
var _includes3 = _interopRequireDefault(_includes2);
var _find2 = require('lodash/find');
var _find3 = _interopRequireDefault(_find2);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.getEmptyRepliesListing = getEmptyRepliesListing;

@@ -59,13 +19,20 @@ exports.addEmptyRepliesListing = addEmptyRepliesListing;

exports.requiredArg = requiredArg;
exports.isBrowser = exports.formatLivethreadPermissions = exports.formatModPermissions = void 0;
var _util = require('util');
var _util = _interopRequireDefault(require("util"));
var _util2 = _interopRequireDefault(_util);
var _lodash = require("lodash");
var _constants = require('./constants.js');
var _constants = require("./constants.js");
var _More = require('./objects/More.js');
var _More = require("./objects/More.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -80,5 +47,7 @@ * @summary Returns an unfetched empty replies Listing for an item.

return item._r._newObject('Listing', {
_uri: 'comments/' + (item.link_id || item.parent_id).slice(3),
_query: { comment: item.name.slice(3) },
_transform: (0, _property3.default)('comments[0].replies'),
_uri: "comments/".concat((item.link_id || item.parent_id).slice(3)),
_query: {
comment: item.name.slice(3)
},
_transform: (0, _lodash.property)('comments[0].replies'),
_link_id: item.link_id,

@@ -88,12 +57,13 @@ _isCommentList: true

}
if (item.constructor._name === 'Submission') {
return item._r._newObject('Listing', {
_uri: 'comments/' + item.id,
_transform: (0, _property3.default)('comments'),
_uri: "comments/".concat(item.id),
_transform: (0, _lodash.property)('comments'),
_isCommentList: true
});
}
return item._r._newObject('Listing');
}
/**

@@ -105,2 +75,4 @@ * @summary Adds an empty replies Listing to an item.

*/
function addEmptyRepliesListing(item) {

@@ -113,9 +85,9 @@ item.replies = getEmptyRepliesListing(item);

return function (response) {
if ((0, _isEmpty3.default)(response) || (0, _isEmpty3.default)(response.json.errors)) {
if ((0, _lodash.isEmpty)(response) || (0, _lodash.isEmpty)(response.json.errors)) {
return returnValue;
}
throw new Error(response.json.errors[0]);
};
}
/**

@@ -128,6 +100,7 @@ * @summary Performs a depth-first search of a tree of private messages, in order to find a message with a given name.

*/
function findMessageInTree(desiredName, rootNode) {
return rootNode.name === desiredName ? rootNode : (0, _find3.default)(rootNode.replies.map((0, _partial3.default)(findMessageInTree, desiredName)));
return rootNode.name === desiredName ? rootNode : (0, _lodash.find)(rootNode.replies.map((0, _lodash.partial)(findMessageInTree, desiredName)));
}
/**

@@ -140,11 +113,13 @@ * @summary Formats permissions into a '+'/'-' string

*/
function formatPermissions(allPermissionNames, permsArray) {
return permsArray ? allPermissionNames.map(function (type) {
return ((0, _includes3.default)(permsArray, type) ? '+' : '-') + type;
return ((0, _lodash.includes)(permsArray, type) ? '+' : '-') + type;
}).join(',') : '+all';
}
var formatModPermissions = exports.formatModPermissions = (0, _partial3.default)(formatPermissions, _constants.MODERATOR_PERMISSIONS);
var formatLivethreadPermissions = exports.formatLivethreadPermissions = (0, _partial3.default)(formatPermissions, _constants.LIVETHREAD_PERMISSIONS);
var formatModPermissions = (0, _lodash.partial)(formatPermissions, _constants.MODERATOR_PERMISSIONS);
exports.formatModPermissions = formatModPermissions;
var formatLivethreadPermissions = (0, _lodash.partial)(formatPermissions, _constants.LIVETHREAD_PERMISSIONS);
/**

@@ -158,6 +133,10 @@ * @summary Renames a key on an object, omitting the old key

*/
exports.formatLivethreadPermissions = formatLivethreadPermissions;
function renameKey(obj, oldKey, newKey) {
return obj && (0, _omit3.default)(_extends({}, obj, { [newKey]: obj[oldKey] }), oldKey);
return obj && (0, _lodash.omit)(_objectSpread({}, obj, {
[newKey]: obj[oldKey]
}), oldKey);
}
/**

@@ -172,4 +151,6 @@ * @summary Builds a replies tree from a list of child comments or messages

*/
function buildRepliesTree(childList) {
var childMap = (0, _keyBy3.default)(childList, 'name');
var childMap = (0, _lodash.keyBy)(childList, 'name');
childList.forEach(addEmptyRepliesListing);

@@ -181,3 +162,3 @@ childList.filter(function (child) {

});
(0, _remove3.default)(childList, function (child) {
(0, _lodash.remove)(childList, function (child) {
return childMap[child.parent_id];

@@ -187,2 +168,3 @@ }).forEach(function (child) {

childMap[child.parent_id].replies._setMore(child);
child.link_id = childMap[child.parent_id].link_id;

@@ -195,3 +177,2 @@ } else {

}
/**

@@ -204,2 +185,4 @@ * @summary Adds a fullname prefix to an item, if it doesn't have a prefix already. If the item is a RedditContent object, gets

*/
function addFullnamePrefix(item, prefix) {

@@ -209,5 +192,5 @@ if (typeof item === 'string') {

}
return item.name;
}
/**

@@ -219,7 +202,7 @@ * @summary Determines whether a string is a "fullname". A "fullname" starts with "t1_", "t2_", ... "t8_", or "LiveUpdateEvent_".

*/
function hasFullnamePrefix(item) {
return (/^(t\d|LiveUpdateEvent)_/.test(item)
);
return /^(t\d|LiveUpdateEvent)_/.test(item);
}
/**

@@ -235,11 +218,16 @@ * @summary Adds snake_case getters and setters to an object

*/
function addSnakeCaseShadowProps(obj) {
Object.keys(obj).filter(function (key) {
return !key.startsWith('_') && key !== (0, _snakeCase3.default)(key);
return !key.startsWith('_') && key !== (0, _lodash.snakeCase)(key);
}).forEach(function (key) {
Object.defineProperty(obj, (0, _snakeCase3.default)(key), { get: function () {
Object.defineProperty(obj, (0, _lodash.snakeCase)(key), {
get: function () {
return obj[key];
}, set: function (value) {
},
set: function (value) {
return obj[key] = value;
} });
}
});
});

@@ -249,3 +237,4 @@ return obj;

var isBrowser = exports.isBrowser = typeof self === 'object';
var isBrowser = typeof self === 'object';
exports.isBrowser = isBrowser;

@@ -255,10 +244,15 @@ function defineInspectFunc(obj, inspectFunc) {

return;
}
// Use the util.inspect.custom symbol if available (Node 6.6.0+)
var inspectKey = _util2.default.inspect && typeof _util2.default.inspect.custom === 'symbol' ? _util2.default.inspect.custom : 'inspect';
Object.defineProperty(obj, inspectKey, { writable: true, enumerable: false, value: inspectFunc });
} // Use the util.inspect.custom symbol if available (Node 6.6.0+)
var inspectKey = _util.default.inspect && typeof _util.default.inspect.custom === 'symbol' ? _util.default.inspect.custom : 'inspect';
Object.defineProperty(obj, inspectKey, {
writable: true,
enumerable: false,
value: inspectFunc
});
}
function requiredArg(argName) {
throw new TypeError('Missing required argument ' + argName);
throw new TypeError("Missing required argument ".concat(argName));
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,15 +6,12 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _helpers = require('../helpers.js');
var _helpers = require("../helpers.js");
var _Listing = require('./Listing.js');
var _Listing = _interopRequireDefault(require("./Listing.js"));
var _Listing2 = _interopRequireDefault(_Listing);
var _More = require("./More.js");
var _More = require('./More.js');
var _VoteableContent = _interopRequireDefault(require("./VoteableContent.js"));
var _VoteableContent = require('./VoteableContent.js');
var _VoteableContent2 = _interopRequireDefault(_VoteableContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -32,5 +29,6 @@

*/
var Comment = class Comment extends _VoteableContent2.default {
var Comment = class Comment extends _VoteableContent.default {
constructor(options, _r, _hasFetched) {
super(options, _r, _hasFetched);
if (_hasFetched) {

@@ -40,3 +38,3 @@ /* If a comment is in a deep comment chain, reddit will send a single `more` object with name `t1__` in place of the

replies should be fetched by sending another request to view the deep comment alone, and parsing the replies from that. */
if (this.replies instanceof _Listing2.default && !this.replies.length && this.replies._more && this.replies._more.name === 't1__') {
if (this.replies instanceof _Listing.default && !this.replies.length && this.replies._more && this.replies._more.name === 't1__') {
this.replies = (0, _helpers.getEmptyRepliesListing)(this);

@@ -46,3 +44,7 @@ } else if (this.replies === '') {

This behavior is unexpected, so replace the empty string with an empty Listing. */
this.replies = this._r._newObject('Listing', { children: [], _more: _More.emptyChildren, _isCommentList: true });
this.replies = this._r._newObject('Listing', {
children: [],
_more: _More.emptyChildren,
_isCommentList: true
});
} else if (this.replies._more && !this.replies._more.link_id) {

@@ -53,7 +55,9 @@ this.replies._more.link_id = this.link_id;

}
_transformApiResponse(response) {
return (0, _helpers.addEmptyRepliesListing)(response[0]);
}
get _uri() {
return 'api/info?id=' + this.name;
return "api/info?id=".concat(this.name);
}

@@ -65,4 +69,11 @@ /**

*/
lock() {
return this._post({ uri: 'api/lock', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/lock',
form: {
id: this.name
}
}).return(this);
}

@@ -74,7 +85,15 @@ /**

*/
unlock() {
return this._post({ uri: 'api/unlock', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unlock',
form: {
id: this.name
}
}).return(this);
}
};
exports.default = Comment;
var _default = Comment;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,138 +6,123 @@ Object.defineProperty(exports, "__esModule", {

});
var _RedditContent = require('./RedditContent.js');
Object.defineProperty(exports, 'RedditContent', {
Object.defineProperty(exports, "RedditContent", {
enumerable: true,
get: function () {
return _interopRequireDefault(_RedditContent).default;
return _RedditContent.default;
}
});
var _ReplyableContent = require('./ReplyableContent.js');
Object.defineProperty(exports, 'ReplyableContent', {
Object.defineProperty(exports, "ReplyableContent", {
enumerable: true,
get: function () {
return _interopRequireDefault(_ReplyableContent).default;
return _ReplyableContent.default;
}
});
var _VoteableContent = require('./VoteableContent.js');
Object.defineProperty(exports, 'VoteableContent', {
Object.defineProperty(exports, "VoteableContent", {
enumerable: true,
get: function () {
return _interopRequireDefault(_VoteableContent).default;
return _VoteableContent.default;
}
});
var _Comment = require('./Comment.js');
Object.defineProperty(exports, 'Comment', {
Object.defineProperty(exports, "Comment", {
enumerable: true,
get: function () {
return _interopRequireDefault(_Comment).default;
return _Comment.default;
}
});
var _RedditUser = require('./RedditUser.js');
Object.defineProperty(exports, 'RedditUser', {
Object.defineProperty(exports, "RedditUser", {
enumerable: true,
get: function () {
return _interopRequireDefault(_RedditUser).default;
return _RedditUser.default;
}
});
var _Submission = require('./Submission.js');
Object.defineProperty(exports, 'Submission', {
Object.defineProperty(exports, "Submission", {
enumerable: true,
get: function () {
return _interopRequireDefault(_Submission).default;
return _Submission.default;
}
});
var _LiveThread = require('./LiveThread.js');
Object.defineProperty(exports, 'LiveThread', {
Object.defineProperty(exports, "LiveThread", {
enumerable: true,
get: function () {
return _interopRequireDefault(_LiveThread).default;
return _LiveThread.default;
}
});
var _PrivateMessage = require('./PrivateMessage.js');
Object.defineProperty(exports, 'PrivateMessage', {
Object.defineProperty(exports, "PrivateMessage", {
enumerable: true,
get: function () {
return _interopRequireDefault(_PrivateMessage).default;
return _PrivateMessage.default;
}
});
var _Subreddit = require('./Subreddit.js');
Object.defineProperty(exports, 'Subreddit', {
Object.defineProperty(exports, "Subreddit", {
enumerable: true,
get: function () {
return _interopRequireDefault(_Subreddit).default;
return _Subreddit.default;
}
});
var _MultiReddit = require('./MultiReddit.js');
Object.defineProperty(exports, 'MultiReddit', {
Object.defineProperty(exports, "MultiReddit", {
enumerable: true,
get: function () {
return _interopRequireDefault(_MultiReddit).default;
return _MultiReddit.default;
}
});
var _WikiPage = require('./WikiPage.js');
Object.defineProperty(exports, 'WikiPage', {
Object.defineProperty(exports, "WikiPage", {
enumerable: true,
get: function () {
return _interopRequireDefault(_WikiPage).default;
return _WikiPage.default;
}
});
var _Listing = require('./Listing.js');
Object.defineProperty(exports, 'Listing', {
Object.defineProperty(exports, "Listing", {
enumerable: true,
get: function () {
return _interopRequireDefault(_Listing).default;
return _Listing.default;
}
});
var _More = require('./More.js');
Object.defineProperty(exports, 'More', {
Object.defineProperty(exports, "More", {
enumerable: true,
get: function () {
return _interopRequireDefault(_More).default;
return _More.default;
}
});
var _UserList = require('./UserList.js');
Object.defineProperty(exports, 'UserList', {
Object.defineProperty(exports, "UserList", {
enumerable: true,
get: function () {
return _interopRequireDefault(_UserList).default;
return _UserList.default;
}
});
var _ModmailConversation = require('./ModmailConversation.js');
Object.defineProperty(exports, 'ModmailConversation', {
Object.defineProperty(exports, "ModmailConversation", {
enumerable: true,
get: function () {
return _interopRequireDefault(_ModmailConversation).default;
return _ModmailConversation.default;
}
});
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _ReplyableContent = _interopRequireDefault(require("./ReplyableContent.js"));
var _VoteableContent = _interopRequireDefault(require("./VoteableContent.js"));
var _Comment = _interopRequireDefault(require("./Comment.js"));
var _RedditUser = _interopRequireDefault(require("./RedditUser.js"));
var _Submission = _interopRequireDefault(require("./Submission.js"));
var _LiveThread = _interopRequireDefault(require("./LiveThread.js"));
var _PrivateMessage = _interopRequireDefault(require("./PrivateMessage.js"));
var _Subreddit = _interopRequireDefault(require("./Subreddit.js"));
var _MultiReddit = _interopRequireDefault(require("./MultiReddit.js"));
var _WikiPage = _interopRequireDefault(require("./WikiPage.js"));
var _Listing = _interopRequireDefault(require("./Listing.js"));
var _More = _interopRequireDefault(require("./More.js"));
var _UserList = _interopRequireDefault(require("./UserList.js"));
var _ModmailConversation = _interopRequireDefault(require("./ModmailConversation.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,51 +6,36 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _pick2 = require('lodash/pick');
var _lodash = require("lodash");
var _pick3 = _interopRequireDefault(_pick2);
var _Promise = _interopRequireDefault(require("../Promise.js"));
var _omitBy2 = require('lodash/omitBy');
var _util = _interopRequireDefault(require("util"));
var _omitBy3 = _interopRequireDefault(_omitBy2);
var _url = require("url");
var _isEmpty2 = require('lodash/isEmpty');
var _helpers = require("../helpers.js");
var _isEmpty3 = _interopRequireDefault(_isEmpty2);
var _errors = require("../errors.js");
var _defaultsDeep2 = require('lodash/defaultsDeep');
var _More = _interopRequireWildcard(require("./More.js"));
var _defaultsDeep3 = _interopRequireDefault(_defaultsDeep2);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
var _defaults2 = require('lodash/defaults');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _defaults3 = _interopRequireDefault(_defaults2);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
var _clone2 = require('lodash/clone');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var _clone3 = _interopRequireDefault(_clone2);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var _Promise = require('../Promise.js');
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
var _Promise2 = _interopRequireDefault(_Promise);
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
var _util = require('util');
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _util2 = _interopRequireDefault(_util);
var _url = require('url');
var _helpers = require('../helpers.js');
var _errors = require('../errors.js');
var _More = require('./More.js');
var _More2 = _interopRequireDefault(_More);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var INTERNAL_DEFAULTS = {

@@ -68,3 +53,2 @@ _query: {},

};
/**

@@ -91,8 +75,11 @@ * A class representing a list of content. This is a subclass of the native Array object, so it has all the properties of

*/
var Listing = class Listing extends Array {
constructor() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _r = arguments[1];
var _r = arguments.length > 1 ? arguments[1] : undefined;
super();
if (!(this instanceof Listing)) {

@@ -104,15 +91,19 @@ // Safari 9 has an incorrect implementation of classes that extend Arrays. As a workaround,

}
this.push.apply(this, _toConsumableArray(options.children || []));
this._r = _r;
this._cachedLookahead = options._cachedLookahead;
(0, _defaultsDeep3.default)(this, (0, _pick3.default)(options, Object.keys(INTERNAL_DEFAULTS)), INTERNAL_DEFAULTS);
Object.assign(this._query, (0, _pick3.default)(options, ['before', 'after']));
if (options.children && options.children[options.children.length - 1] instanceof _More2.default) {
(0, _lodash.defaultsDeep)(this, (0, _lodash.pick)(options, Object.keys(INTERNAL_DEFAULTS)), INTERNAL_DEFAULTS);
Object.assign(this._query, (0, _lodash.pick)(options, ['before', 'after']));
if (options.children && options.children[options.children.length - 1] instanceof _More.default) {
this._setMore(this.pop());
}
}
_setUri(value) {
var parsedUri = (0, _url.parse)(value, true);
this._uri = parsedUri.pathname;
(0, _defaultsDeep3.default)(this._query, parsedUri.query);
(0, _lodash.defaultsDeep)(this._query, parsedUri.query);
if (parsedUri.query.before) {

@@ -128,2 +119,4 @@ this._query.after = null;

*/
get isFinished() {

@@ -135,3 +128,3 @@ // The process of checking whether a Listing is 'finished' varies depending on what kind of Listing it is.

no cached lookahead, a Listing is finished iff it has an empty `more` object. */
? (0, _isEmpty3.default)(this._cachedLookahead) && !!this._more && (0, _isEmpty3.default)(this._more.children)
? (0, _lodash.isEmpty)(this._cachedLookahead) && !!this._more && (0, _lodash.isEmpty)(this._more.children)
/* For non-comment Listings: A Listing is always finished if it has no URI (since there would be nowhere to fetch items

@@ -144,2 +137,3 @@ from). If it has a URI, a Listing is finished iff its `before` and `after` query are both `null`. This is because reddit

}
get is_finished() {

@@ -176,25 +170,38 @@ // camel-case alias for backwards-compatibility.

*/
fetchMore(options) {
var parsedOptions = (0, _defaults3.default)(typeof options === 'number' ? { amount: options } : (0, _clone3.default)(options),
// Accept either `skip_replies` or `skipReplies` for backwards compatibility.
{ append: true, skipReplies: options.skip_replies });
var parsedOptions = (0, _lodash.defaults)(typeof options === 'number' ? {
amount: options
} : (0, _lodash.clone)(options), // Accept either `skip_replies` or `skipReplies` for backwards compatibility.
{
append: true,
skipReplies: options.skip_replies
});
if (typeof parsedOptions.amount !== 'number' || Number.isNaN(parsedOptions.amount)) {
throw new _errors.InvalidMethodCallError('Failed to fetch Listing. (`amount` parameter was missing or invalid)');
}
if (parsedOptions.amount <= 0 || this.isFinished) {
return this._r._promiseWrap(_Promise2.default.resolve(parsedOptions.append ? this._clone() : this._clone()._empty()));
return this._r._promiseWrap(_Promise.default.resolve(parsedOptions.append ? this._clone() : this._clone()._empty()));
}
if (this._cachedLookahead) {
var cloned = this._clone();
cloned.push.apply(cloned, _toConsumableArray(cloned._cachedLookahead.splice(0, parsedOptions.amount)));
return cloned.fetchMore(parsedOptions.amount - cloned.length + this.length);
}
return this._r._promiseWrap(this._more ? this._fetchMoreComments(parsedOptions) : this._fetchMoreRegular(parsedOptions));
}
_fetchMoreRegular(options) {
var _this = this;
var query = (0, _omitBy3.default)((0, _clone3.default)(this._query), function (value) {
var query = (0, _lodash.omitBy)((0, _lodash.clone)(this._query), function (value) {
return value === null || value === undefined;
});
if (!this._isCommentList) {

@@ -215,2 +222,3 @@ /* Reddit returns a different number of items per request depending on the `limit` querystring property specified in the

}
return this._r.oauthRequest({

@@ -222,5 +230,7 @@ uri: this._uri,

var cloned = _this._clone();
if (!options.append) {
cloned._empty();
}
if (cloned._query.before) {

@@ -235,4 +245,6 @@ cloned.unshift.apply(cloned, _toConsumableArray(response));

}
if (_this._isCommentList) {
cloned._more = cloned._more || response._more || _More.emptyChildren;
if (response.length > options.amount) {

@@ -242,3 +254,7 @@ cloned._cachedLookahead = Array.from(cloned.splice(options.amount));

}
return cloned.fetchMore(_extends({}, options, { append: true, amount: options.amount - response.length }));
return cloned.fetchMore(_objectSpread({}, options, {
append: true,
amount: options.amount - response.length
}));
});

@@ -249,2 +265,4 @@ }

in the thread. */
_fetchMoreComments(options) {

@@ -255,5 +273,7 @@ var _this2 = this;

var cloned = _this2._clone();
if (!options.append) {
cloned._empty();
}
cloned.push.apply(cloned, _toConsumableArray(moreComments));

@@ -274,24 +294,37 @@ cloned._more.children = cloned._more.children.slice(options.amount);

*/
fetchAll(options) {
return this.fetchMore(_extends({}, options, { amount: Infinity }));
return this.fetchMore(_objectSpread({}, options, {
amount: Infinity
}));
}
fetchUntil(options) {
this._r._warn('Listing#fetchUntil is deprecated -- use Listing#fetchMore instead.');
return this.fetchMore(_extends({}, options, { append: true, amount: options.length - this.length }));
return this.fetchMore(_objectSpread({}, options, {
append: true,
amount: options.length - this.length
}));
}
_clone() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$deep = _ref.deep,
deep = _ref$deep === undefined ? false : _ref$deep;
deep = _ref$deep === void 0 ? false : _ref$deep;
var properties = (0, _pick3.default)(this, Object.keys(INTERNAL_DEFAULTS));
properties._query = (0, _clone3.default)(properties._query);
properties._cachedLookahead = (0, _clone3.default)(properties._cachedLookahead);
var properties = (0, _lodash.pick)(this, Object.keys(INTERNAL_DEFAULTS));
properties._query = (0, _lodash.clone)(properties._query);
properties._cachedLookahead = (0, _lodash.clone)(properties._cachedLookahead);
properties._more = this._more && this._more._clone();
var shallowChildren = Array.from(this);
properties.children = deep ? shallowChildren.map(function (item) {
return '_clone' in item && typeof item._clone === 'function' ? item._clone({ deep }) : item;
return '_clone' in item && typeof item._clone === 'function' ? item._clone({
deep
}) : item;
}) : shallowChildren;
return new Listing(properties, this._r);
}
_setMore(moreObj) {

@@ -301,2 +334,3 @@ this._more = moreObj;

}
_empty() {

@@ -306,2 +340,3 @@ this.splice(0, this.length);

}
toJSON() {

@@ -312,8 +347,8 @@ return Array.from(this).map(function (item) {

}
};
(0, _helpers.defineInspectFunc)(Listing.prototype, function () {
return 'Listing ' + _util2.default.inspect(Array.from(this));
return "Listing ".concat(_util.default.inspect(Array.from(this)));
});
exports.default = Listing;
var _default = Listing;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,17 +6,14 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _events = require('events');
var _events = require("events");
var _helpers = require('../helpers.js');
var _helpers = require("../helpers.js");
var _RedditContent = require('./RedditContent.js');
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var WebSocket = _helpers.isBrowser ? global.WebSocket : require('ws');
var api_type = 'json';
/**

@@ -57,21 +54,29 @@ * A class representing a live reddit thread

*/
var LiveThread = class LiveThread extends _RedditContent2.default {
var LiveThread = class LiveThread extends _RedditContent.default {
constructor(options, _r, _hasFetched) {
var _this;
_this = super(options, _r, _hasFetched);
super(options, _r, _hasFetched);
_this = this;
this._rawStream = null;
this._populatedStream = null;
if (_hasFetched) {
Object.defineProperty(this, 'stream', { get: function () {
Object.defineProperty(this, 'stream', {
get: function () {
if (!_this._populatedStream && _this.websocket_url) {
_this._setupWebSocket();
}
return _this._populatedStream;
} });
}
});
}
}
get _uri() {
return 'live/' + this.id + '/about';
return "live/".concat(this.id, "/about");
}
_setupWebSocket() {

@@ -82,6 +87,9 @@ var _this2 = this;

this._populatedStream = new _events.EventEmitter();
var handler = function (data) {
var parsed = _this2._r._populate(JSON.parse(data));
_this2._populatedStream.emit(parsed.type, parsed.payload);
};
if (typeof this._rawStream.on === 'function') {

@@ -101,4 +109,12 @@ this._rawStream.on('message', handler);

*/
addUpdate(body) {
return this._post({ uri: 'api/live/' + this.id + '/update', form: { api_type, body } }).then((0, _helpers.handleJsonErrors)(this));
return this._post({
uri: "api/live/".concat(this.id, "/update"),
form: {
api_type,
body
}
}).then((0, _helpers.handleJsonErrors)(this));
}

@@ -112,8 +128,12 @@ /**

*/
strikeUpdate(_ref) {
var id = _ref.id;
return this._post({
uri: 'api/live/' + this.id + '/strike_update',
form: { api_type, id: '' + (id.startsWith('LiveUpdate_') ? '' : 'LiveUpdate_') + id }
uri: "api/live/".concat(this.id, "/strike_update"),
form: {
api_type,
id: "".concat(id.startsWith('LiveUpdate_') ? '' : 'LiveUpdate_').concat(id)
}
}).then((0, _helpers.handleJsonErrors)(this));

@@ -128,8 +148,12 @@ }

*/
deleteUpdate(_ref2) {
var id = _ref2.id;
return this._post({
uri: 'api/live/' + this.id + '/delete_update',
form: { api_type, id: '' + (id.startsWith('LiveUpdate_') ? '' : 'LiveUpdate_') + id }
uri: "api/live/".concat(this.id, "/delete_update"),
form: {
api_type,
id: "".concat(id.startsWith('LiveUpdate_') ? '' : 'LiveUpdate_').concat(id)
}
}).then((0, _helpers.handleJsonErrors)(this));

@@ -148,4 +172,8 @@ }

*/
getContributors() {
return this._get({ uri: 'live/' + this.id + '/contributors' }).then(function (contributors) {
return this._get({
uri: "live/".concat(this.id, "/contributors")
}).then(function (contributors) {
return Array.isArray(contributors[0]) ? contributors[0] : contributors;

@@ -163,7 +191,10 @@ });

*/
inviteContributor(_ref3) {
var name = _ref3.name,
permissions = _ref3.permissions;
return this._post({ uri: 'api/live/' + this.id + '/invite_contributor', form: {
return this._post({
uri: "api/live/".concat(this.id, "/invite_contributor"),
form: {
api_type,

@@ -173,3 +204,4 @@ name,

type: 'liveupdate_contributor_invite'
} }).then((0, _helpers.handleJsonErrors)(this));
}
}).then((0, _helpers.handleJsonErrors)(this));
}

@@ -183,2 +215,4 @@ /**

*/
revokeContributorInvite(_ref4) {

@@ -188,5 +222,10 @@ var _this3 = this;

var name = _ref4.name;
return this._r.getUser(name).fetch().get('id').then(function (userId) {
return _this3._post({ uri: 'api/live/' + _this3.id + '/rm_contributor_invite', form: { api_type, id: 't2_' + userId } });
return _this3._post({
uri: "api/live/".concat(_this3.id, "/rm_contributor_invite"),
form: {
api_type,
id: "t2_".concat(userId)
}
});
}).then((0, _helpers.handleJsonErrors)(this));

@@ -199,4 +238,11 @@ }

*/
acceptContributorInvite() {
return this._post({ uri: 'api/live/' + this.id + '/accept_contributor_invite', form: { api_type } }).return(this);
return this._post({
uri: "api/live/".concat(this.id, "/accept_contributor_invite"),
form: {
api_type
}
}).return(this);
}

@@ -208,4 +254,11 @@ /**

*/
leaveContributor() {
return this._post({ uri: 'api/live/' + this.id + '/leave_contributor', form: { api_type } }).return(this);
return this._post({
uri: "api/live/".concat(this.id, "/leave_contributor"),
form: {
api_type
}
}).return(this);
}

@@ -219,2 +272,4 @@ /**

*/
removeContributor(_ref5) {

@@ -224,5 +279,10 @@ var _this4 = this;

var name = _ref5.name;
return this._r.getUser(name).fetch().get('id').then(function (userId) {
return _this4._post({ uri: 'api/live/' + _this4.id + '/rm_contributor', form: { api_type, id: 't2_' + userId } });
return _this4._post({
uri: "api/live/".concat(_this4.id, "/rm_contributor"),
form: {
api_type,
id: "t2_".concat(userId)
}
});
}).then((0, _helpers.handleJsonErrors)(this));

@@ -239,9 +299,15 @@ }

*/
setContributorPermissions(_ref6) {
var name = _ref6.name,
permissions = _ref6.permissions;
return this._post({
uri: 'api/live/' + this.id + '/set_contributor_permissions',
form: { api_type, name, permissions: (0, _helpers.formatLivethreadPermissions)(permissions), type: 'liveupdate_contributor' }
uri: "api/live/".concat(this.id, "/set_contributor_permissions"),
form: {
api_type,
name,
permissions: (0, _helpers.formatLivethreadPermissions)(permissions),
type: 'liveupdate_contributor'
}
}).then((0, _helpers.handleJsonErrors)(this));

@@ -259,2 +325,4 @@ }

*/
editSettings(_ref7) {

@@ -265,6 +333,11 @@ var title = _ref7.title,

nsfw = _ref7.nsfw;
return this._post({
uri: 'api/live/' + this.id + '/edit',
form: { api_type, description, nsfw, resources, title }
uri: "api/live/".concat(this.id, "/edit"),
form: {
api_type,
description,
nsfw,
resources,
title
}
}).then((0, _helpers.handleJsonErrors)(this));

@@ -277,4 +350,11 @@ }

*/
closeThread() {
return this._post({ uri: 'api/live/' + this.id + '/close_thread', form: { api_type } }).return(this);
return this._post({
uri: "api/live/".concat(this.id, "/close_thread"),
form: {
api_type
}
}).return(this);
}

@@ -289,6 +369,13 @@ /**

*/
report(_ref8) {
var reason = _ref8.reason;
return this._post({ uri: 'api/live/' + this.id + '/report', form: { api_type, type: reason } }).then((0, _helpers.handleJsonErrors)(this));
return this._post({
uri: "api/live/".concat(this.id, "/report"),
form: {
api_type,
type: reason
}
}).then((0, _helpers.handleJsonErrors)(this));
}

@@ -308,4 +395,9 @@ /**

*/
getRecentUpdates(options) {
return this._getListing({ uri: 'live/' + this.id, qs: options });
return this._getListing({
uri: "live/".concat(this.id),
qs: options
});
}

@@ -325,4 +417,9 @@ /**

*/
getDiscussions(options) {
return this._getListing({ uri: 'live/' + this.id + '/discussions', qs: options });
return this._getListing({
uri: "live/".concat(this.id, "/discussions"),
qs: options
});
}

@@ -345,2 +442,4 @@ /**

*/
closeStream() {

@@ -351,4 +450,5 @@ if (this._rawStream) {

}
};
exports.default = LiveThread;
var _default = LiveThread;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {

});
exports.modActionStates = exports.conversationStates = undefined;
exports.default = exports.modActionStates = exports.conversationStates = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent = require('./RedditContent.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -21,3 +23,3 @@ * @summary Represents the current status of a given Modmail conversation.

*/
var conversationStates = exports.conversationStates = Object.freeze({
var conversationStates = Object.freeze({
New: 0,

@@ -27,3 +29,2 @@ InProgress: 1,

});
/**

@@ -33,3 +34,5 @@ * @summary Represents all the possible states that is used within a Modmail conversations.

*/
var modActionStates = exports.modActionStates = Object.freeze({
exports.conversationStates = conversationStates;
var modActionStates = Object.freeze({
Highlight: 0,

@@ -43,3 +46,2 @@ UnHighlight: 1,

});
/**

@@ -54,4 +56,5 @@ * A class representing a conversation from new modmail

*/
var ModmailConversation = class ModmailConversation extends _RedditContent2.default {
exports.modActionStates = modActionStates;
var ModmailConversation = class ModmailConversation extends _RedditContent.default {
static get conversationStates() {

@@ -66,5 +69,4 @@ return conversationStates;

get _uri() {
return 'api/mod/conversations/' + this.id + '?markRead=false';
return "api/mod/conversations/".concat(this.id, "?markRead=false");
}
/**

@@ -76,2 +78,4 @@ * @summary Converts relevant fields in the ModmailConversation to snoowrap models.

*/
_transformApiResponse(response) {

@@ -83,2 +87,3 @@ response.conversation.owner = this._r._newObject('Subreddit', {

response.conversation.participant = this._r._newObject('ModmailConversationAuthor', response.user.name, true);
for (var author of response.conversation.authors) {

@@ -89,5 +94,5 @@ author = this._r._newObject('ModmailConversationAuthor', author, true);

var conversationObjects = ModmailConversation._getConversationObjects(response.conversation, response);
return this._r._newObject('ModmailConversation', _extends({}, conversationObjects, response.conversation), true);
return this._r._newObject('ModmailConversation', _objectSpread({}, conversationObjects, {}, response.conversation), true);
}
/**

@@ -100,4 +105,7 @@ * @summary Maps objects to the ModmailConversation

*/
static _getConversationObjects(conversation, response) {
var conversationObjects = {};
for (var objId of conversation.objIds) {

@@ -107,7 +115,8 @@ if (!conversationObjects[objId.key]) {

}
conversationObjects[objId.key].push(response[objId.key][objId.id]);
}
return conversationObjects;
}
/**

@@ -120,6 +129,9 @@ * @summary Archives the ModmailConversation

*/
archive() {
return this._post({ uri: 'api/mod/conversations/' + this.id + '/archive' });
return this._post({
uri: "api/mod/conversations/".concat(this.id, "/archive")
});
}
/**

@@ -132,6 +144,9 @@ * @summary Unarchives the ModmailConversation

*/
unarchive() {
return this._post({ uri: 'api/mod/conversations/' + this.id + '/unarchive' });
return this._post({
uri: "api/mod/conversations/".concat(this.id, "/unarchive")
});
}
/**

@@ -144,6 +159,9 @@ * @summary Marks a ModmailConversation as highlighted

*/
highlight() {
return this._post({ uri: 'api/mod/conversations/' + this.id + '/highlight' });
return this._post({
uri: "api/mod/conversations/".concat(this.id, "/highlight")
});
}
/**

@@ -156,6 +174,9 @@ * @summary Removed highlighted from a ModmailConversation

*/
unhighlight() {
return this._delete({ uri: 'api/mod/conversations/' + this.id + '/highlight' });
return this._delete({
uri: "api/mod/conversations/".concat(this.id, "/highlight")
});
}
/**

@@ -168,6 +189,9 @@ * @summary Mute the participant of the ModmailConversation

*/
mute() {
return this._post({ uri: 'api/mod/conversations/' + this.id + '/mute' });
return this._post({
uri: "api/mod/conversations/".concat(this.id, "/mute")
});
}
/**

@@ -180,6 +204,9 @@ * @summary Unmute the participant of the ModmailConversation

*/
unmute() {
return this._post({ uri: 'api/mod/conversations/' + this.id + '/unmute' });
return this._post({
uri: "api/mod/conversations/".concat(this.id, "/unmute")
});
}
/**

@@ -192,6 +219,7 @@ * @summary Marks the ModmailConversation as read

*/
read() {
return this._r.markNewModmailConversationsAsRead([this.id]);
}
/**

@@ -204,6 +232,7 @@ * @summary Marks the ModmailConversation as unread

*/
unread() {
return this._r.markNewModmailConversationsAsUnread([this.id]);
}
/**

@@ -217,10 +246,13 @@ * @summary Fetches the participant of the conversation

*/
getParticipant() {
var _this = this;
return this._get({ uri: 'api/mod/conversations/' + this.id + '/user' }).then(function (res) {
return this._get({
uri: "api/mod/conversations/".concat(this.id, "/user")
}).then(function (res) {
return _this._r._newObject('ModmailConversationAuthor', res, true);
});
}
/**

@@ -230,2 +262,4 @@ * @summary Returns whether the ModmailConversation is read.

*/
isRead() {

@@ -238,4 +272,5 @@ return this.lastUnread === null;

}
};
exports.default = ModmailConversation;
var _default = ModmailConversation;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,11 +6,14 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _RedditContent = _interopRequireDefault(require("./RedditContent"));
var _RedditContent = require('./RedditContent');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -25,17 +28,15 @@ * A class representing an author from a modmail conversation

*/
var ModmailConversationAuthor = class ModmailParticipant extends _RedditContent2.default {
var ModmailConversationAuthor = class ModmailParticipant extends _RedditContent.default {
constructor(options, r, hasFetched) {
var _this;
_this = super(options, r, hasFetched);
super(options, r, hasFetched);
_this = this;
options.recentComments = Object.keys(options.recentComments).map(function (commentId) {
return _this._r._newObject('Comment', _extends({
return _this._r._newObject('Comment', _objectSpread({
name: commentId
}, options.recentComments[commentId]));
});
options.recentPosts = Object.keys(options.recentPosts).map(function (postId) {
return _this._r._newObject('Submission', _extends({
return _this._r._newObject('Submission', _objectSpread({
name: postId

@@ -45,3 +46,2 @@ }, options.recentPosts[postId]));

}
/**

@@ -57,2 +57,4 @@ * @summary Gets information on a Reddit user for the given modmail.

*/
getUser() {

@@ -63,3 +65,3 @@ return this._r.getUser(this.name);

};
exports.default = ModmailConversationAuthor;
var _default = ModmailConversationAuthor;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,38 +6,21 @@ Object.defineProperty(exports, "__esModule", {

});
exports.emptyChildren = undefined;
exports.default = exports.emptyChildren = void 0;
var _remove2 = require('lodash/remove');
var _lodash = require("lodash");
var _remove3 = _interopRequireDefault(_remove2);
var _Promise = _interopRequireDefault(require("../Promise.js"));
var _pick2 = require('lodash/pick');
var _helpers = require("../helpers.js");
var _pick3 = _interopRequireDefault(_pick2);
var _constants = require("../constants.js");
var _forEach2 = require('lodash/forEach');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _forEach3 = _interopRequireDefault(_forEach2);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
var _flatten2 = require('lodash/flatten');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var _flatten3 = _interopRequireDefault(_flatten2);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _concat2 = require('lodash/concat');
var _concat3 = _interopRequireDefault(_concat2);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _Promise = require('../Promise.js');
var _Promise2 = _interopRequireDefault(_Promise);
var _helpers = require('../helpers.js');
var _constants = require('../constants.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var api_type = 'json';
/**

@@ -67,2 +50,4 @@ * The `More` class is a helper representing reddit's exposed `more` type in comment threads, used to fetch additional comments

to /api/info. */
fetchMore(options) {

@@ -72,17 +57,29 @@ var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

if (options.amount <= 0 || startIndex >= this.children.length) {
return _Promise2.default.resolve([]);
return _Promise.default.resolve([]);
}
if (!options.skipReplies) {
return this.fetchTree(options, startIndex);
}
var ids = getNextIdSlice(this.children, startIndex, options.amount, _constants.MAX_API_INFO_AMOUNT).map(function (id) {
return 't1_' + id;
return "t1_".concat(id);
}); // Requests are capped at 100 comments. Send lots of requests recursively to get the comments, then concatenate them.
// (This speed-requesting is only possible with comment Listings since the entire list of ids is present initially.)
var promiseForThisBatch = this._r._getListing({
uri: 'api/info',
qs: {
id: ids.join(',')
}
});
// Requests are capped at 100 comments. Send lots of requests recursively to get the comments, then concatenate them.
// (This speed-requesting is only possible with comment Listings since the entire list of ids is present initially.)
var promiseForThisBatch = this._r._getListing({ uri: 'api/info', qs: { id: ids.join(',') } });
var nextRequestOptions = _extends({}, options, { amount: options.amount - ids.length });
var nextRequestOptions = _objectSpread({}, options, {
amount: options.amount - ids.length
});
var promiseForRemainingItems = this.fetchMore(nextRequestOptions, startIndex + ids.length);
return _Promise2.default.all([promiseForThisBatch, promiseForRemainingItems]).then(_flatten3.default);
return _Promise.default.all([promiseForThisBatch, promiseForRemainingItems]).then(_lodash.flatten);
}
fetchTree(options, startIndex) {

@@ -92,8 +89,13 @@ var _this = this;

if (options.amount <= 0 || startIndex >= this.children.length) {
return _Promise2.default.resolve([]);
return _Promise.default.resolve([]);
}
var ids = getNextIdSlice(this.children, startIndex, options.amount, _constants.MAX_API_MORECHILDREN_AMOUNT);
return this._r._get({
uri: 'api/morechildren',
qs: { api_type, children: ids.join(','), link_id: this.link_id || this.parent_id }
qs: {
api_type,
children: ids.join(','),
link_id: this.link_id || this.parent_id
}
}).tap(_helpers.handleJsonErrors).then(function (res) {

@@ -105,13 +107,17 @@ return res.json.data.things;

In these cases, recursively fetch the smaller `more` objects as well. */
var childMores = (0, _remove3.default)(resultTrees, function (c) {
var childMores = (0, _lodash.remove)(resultTrees, function (c) {
return c instanceof More;
});
(0, _forEach3.default)(childMores, function (c) {
(0, _lodash.forEach)(childMores, function (c) {
c.link_id = _this.link_id || _this.parent_id;
});
return _Promise2.default.mapSeries(childMores, function (c) {
return c.fetchTree(_extends({}, options, { amount: Infinity }), 0);
return _Promise.default.mapSeries(childMores, function (c) {
return c.fetchTree(_objectSpread({}, options, {
amount: Infinity
}), 0);
}).then(function (expandedTrees) {
return _this.fetchMore(_extends({}, options, { amount: options.amount - ids.length }), startIndex + ids.length).then(function (nexts) {
return (0, _concat3.default)(resultTrees, (0, _flatten3.default)(expandedTrees), nexts);
return _this.fetchMore(_objectSpread({}, options, {
amount: options.amount - ids.length
}), startIndex + ids.length).then(function (nexts) {
return (0, _lodash.concat)(resultTrees, (0, _lodash.flatten)(expandedTrees), nexts);
});

@@ -121,5 +127,7 @@ });

}
_clone() {
return new More((0, _pick3.default)(this, Object.getOwnPropertyNames(this)), this._r);
return new More((0, _lodash.pick)(this, Object.getOwnPropertyNames(this)), this._r);
}
};

@@ -131,3 +139,7 @@

var emptyChildren = exports.emptyChildren = new More({ children: [] });
exports.default = More;
var emptyChildren = new More({
children: []
});
exports.emptyChildren = emptyChildren;
var _default = More;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _RedditContent = require('./RedditContent.js');
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -22,19 +21,25 @@

*/
var MultiReddit = class MultiReddit extends _RedditContent2.default {
var MultiReddit = class MultiReddit extends _RedditContent.default {
constructor(options, _r, _hasFetched) {
var _this;
_this = super(options, _r, _hasFetched);
super(options, _r, _hasFetched);
_this = this;
if (_hasFetched) {
this.curator = _r.getUser(this.path.split('/')[2]);
this.subreddits = this.subreddits.map(function (item) {
return _this._r._newObject('Subreddit', item.data || { display_name: item.name });
return _this._r._newObject('Subreddit', item.data || {
display_name: item.name
});
});
}
}
get _uri() {
return 'api/multi' + this._path + '?expand_srs=true';
return "api/multi".concat(this._path, "?expand_srs=true");
}
get _path() {
return '/user/' + this.curator.name + '/m/' + this.name;
return "/user/".concat(this.curator.name, "/m/").concat(this.name);
}

@@ -48,2 +53,4 @@ /**

*/
copy(_ref) {

@@ -54,10 +61,12 @@ var _this2 = this;

_ref$newName = _ref.newName,
newName = _ref$newName === undefined ? new_name : _ref$newName;
newName = _ref$newName === void 0 ? new_name : _ref$newName;
return this._r._getMyName().then(function (name) {
return _this2._post({ uri: 'api/multi/copy', form: {
return _this2._post({
uri: 'api/multi/copy',
form: {
from: _this2._path,
to: '/user/' + name + '/m/' + newName,
to: "/user/".concat(name, "/m/").concat(newName),
display_name: newName
} });
}
});
});

@@ -74,2 +83,4 @@ }

*/
rename(_ref2) {

@@ -80,8 +91,11 @@ var _this3 = this;

_ref2$newName = _ref2.newName,
newName = _ref2$newName === undefined ? new_name : _ref2$newName;
newName = _ref2$newName === void 0 ? new_name : _ref2$newName;
return this._r._getMyName().then(function (name) {
return _this3._post({
uri: 'api/multi/rename',
form: { from: _this3._path, to: '/user/' + name + '/m/' + newName, display_name: newName }
form: {
from: _this3._path,
to: "/user/".concat(name, "/m/").concat(newName),
display_name: newName
}
});

@@ -108,5 +122,7 @@ }).then(function (res) {

*/
edit(_ref3) {
var _ref3$name = _ref3.name,
name = _ref3$name === undefined ? '' : _ref3$name,
name = _ref3$name === void 0 ? '' : _ref3$name,
description = _ref3.description,

@@ -117,5 +133,7 @@ icon_name = _ref3.icon_name,

weighting_scheme = _ref3.weighting_scheme;
var display_name = name.length ? name : this.name;
return this._put({ uri: 'api/multi' + this._path, form: { model: JSON.stringify({
return this._put({
uri: "api/multi".concat(this._path),
form: {
model: JSON.stringify({
description_md: description,

@@ -127,3 +145,5 @@ display_name,

weighting_scheme
}) } });
})
}
});
}

@@ -136,5 +156,14 @@ /**

*/
addSubreddit(sub) {
sub = typeof sub === 'string' ? sub : sub.display_name;
return this._put({ uri: 'api/multi' + this._path + '/r/' + sub, form: { model: JSON.stringify({ name: sub }) } }).return(this);
return this._put({
uri: "api/multi".concat(this._path, "/r/").concat(sub),
form: {
model: JSON.stringify({
name: sub
})
}
}).return(this);
}

@@ -147,10 +176,15 @@ /**

*/
removeSubreddit(sub) {
return this._delete({ uri: 'api/multi' + this._path + '/r/' + (typeof sub === 'string' ? sub : sub.display_name) }).return(this);
return this._delete({
uri: "api/multi".concat(this._path, "/r/").concat(typeof sub === 'string' ? sub : sub.display_name)
}).return(this);
}
/* Note: The endpoints GET/PUT /api/multi/multipath/description and GET /api/multi/multipath/r/srname are intentionally not
included, because they're redundant and the same thing can be achieved by simply using fetch() and edit(). */
};
// MultiReddit#delete is not in the class body since Safari 9 can't parse the `delete` function name in class bodies.
}; // MultiReddit#delete is not in the class body since Safari 9 can't parse the `delete` function name in class bodies.
/**

@@ -165,6 +199,14 @@ * @function

*/
Object.defineProperty(MultiReddit.prototype, 'delete', { value() {
return this._delete({ uri: 'api/multi' + this._path });
}, configurable: true, writable: true });
exports.default = MultiReddit;
Object.defineProperty(MultiReddit.prototype, 'delete', {
value() {
return this._delete({
uri: "api/multi".concat(this._path)
});
},
configurable: true,
writable: true
});
var _default = MultiReddit;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _helpers = require('../helpers.js');
var _helpers = require("../helpers.js");
var _ReplyableContent = require('./ReplyableContent.js');
var _ReplyableContent = _interopRequireDefault(require("./ReplyableContent.js"));
var _ReplyableContent2 = _interopRequireDefault(_ReplyableContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -25,11 +24,12 @@

*/
var PrivateMessage = class PrivateMessage extends _ReplyableContent2.default {
var PrivateMessage = class PrivateMessage extends _ReplyableContent.default {
get _uri() {
return 'message/messages/' + this.name.slice(3);
return "message/messages/".concat(this.name.slice(3));
}
_transformApiResponse(response) {
response[0].replies = (0, _helpers.buildRepliesTree)(response[0].replies || []);
return (0, _helpers.findMessageInTree)(this.name, response[0]);
}
// TODO: Get rid of the repeated code here, most of these methods are exactly the same with the exception of the URIs
} // TODO: Get rid of the repeated code here, most of these methods are exactly the same with the exception of the URIs
/**

@@ -40,2 +40,4 @@ * @summary Marks this message as read.

*/
markAsRead() {

@@ -49,2 +51,4 @@ return this._r.markMessagesAsRead([this]).return(this);

*/
markAsUnread() {

@@ -58,4 +62,11 @@ return this._r.markMessagesAsUnread([this]).return(this);

*/
muteAuthor() {
return this._post({ uri: 'api/mute_message_author', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/mute_message_author',
form: {
id: this.name
}
}).return(this);
}

@@ -67,4 +78,11 @@ /**

*/
unmuteAuthor() {
return this._post({ uri: 'api/unmute_message_author', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unmute_message_author',
form: {
id: this.name
}
}).return(this);
}

@@ -80,7 +98,15 @@ /**

*/
deleteFromInbox() {
return this._post({ uri: 'api/del_msg', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/del_msg',
form: {
id: this.name
}
}).return(this);
}
};
exports.default = PrivateMessage;
var _default = PrivateMessage;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,31 +6,16 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _pick2 = require('lodash/pick');
var _lodash = require("lodash");
var _pick3 = _interopRequireDefault(_pick2);
var _Promise = _interopRequireDefault(require("../Promise.js"));
var _mapValues2 = require('lodash/mapValues');
var _util = _interopRequireDefault(require("util"));
var _mapValues3 = _interopRequireDefault(_mapValues2);
var _helpers = require("../helpers.js");
var _cloneDeep2 = require('lodash/cloneDeep');
var _constants = require("../constants.js");
var _cloneDeep3 = _interopRequireDefault(_cloneDeep2);
var _Listing = _interopRequireDefault(require("./Listing.js"));
var _Promise = require('../Promise.js');
var _Promise2 = _interopRequireDefault(_Promise);
var _util = require('util');
var _util2 = _interopRequireDefault(_util);
var _helpers = require('../helpers.js');
var _constants = require('../constants.js');
var _Listing = require('./Listing.js');
var _Listing2 = _interopRequireDefault(_Listing);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -51,6 +36,10 @@

Object.assign(this, options);
if (typeof Proxy !== 'undefined' && !this._hasFetched && _r._config.proxies) {
return new Proxy(this, { get(target, key) {
return key in target || key === 'length' || key in _Promise2.default.prototype ? target[key] : target.fetch()[key];
} });
return new Proxy(this, {
get(target, key) {
return key in target || key === 'length' || key in _Promise.default.prototype ? target[key] : target.fetch()[key];
}
});
}

@@ -83,2 +72,4 @@ }

*/
fetch() {

@@ -88,6 +79,9 @@ var _this = this;

if (!this._fetch) {
this._fetch = this._r._promiseWrap(this._r._get({ uri: this._uri }).then(function (res) {
this._fetch = this._r._promiseWrap(this._r._get({
uri: this._uri
}).then(function (res) {
return _this._transformApiResponse(res);
}));
}
return this._fetch;

@@ -111,2 +105,4 @@ }

*/
refresh() {

@@ -126,4 +122,6 @@ this._fetch = null;

*/
toJSON() {
return (0, _mapValues3.default)(this._stripPrivateProps(), function (value, key) {
return (0, _lodash.mapValues)(this._stripPrivateProps(), function (value, key) {
if (value instanceof RedditContent && !value._hasFetched) {

@@ -133,2 +131,3 @@ if (value.constructor._name === 'RedditUser' && _constants.USER_KEYS.has(key)) {

}
if (value.constructor._name === 'Subreddit' && _constants.SUBREDDIT_KEYS.has(key)) {

@@ -138,22 +137,29 @@ return value.display_name;

}
return value && value.toJSON ? value.toJSON() : value;
});
}
_stripPrivateProps() {
return (0, _pick3.default)(this, Object.keys(this).filter(function (key) {
return (0, _lodash.pick)(this, Object.keys(this).filter(function (key) {
return !key.startsWith('_');
}));
}
_transformApiResponse(response) {
return response;
}
_clone() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$deep = _ref.deep,
deep = _ref$deep === undefined ? false : _ref$deep;
deep = _ref$deep === void 0 ? false : _ref$deep;
var clonedProps = (0, _mapValues3.default)(this, function (value) {
var clonedProps = (0, _lodash.mapValues)(this, function (value) {
if (deep) {
return value instanceof RedditContent || value instanceof _Listing2.default ? value._clone({ deep }) : (0, _cloneDeep3.default)(value);
return value instanceof RedditContent || value instanceof _Listing.default ? value._clone({
deep
}) : (0, _lodash.cloneDeep)(value);
}
return value;

@@ -163,21 +169,28 @@ });

}
_getListing() {
var _r2;
var _this$_r;
return (_r2 = this._r)._getListing.apply(_r2, arguments);
return (_this$_r = this._r)._getListing.apply(_this$_r, arguments);
}
};
(0, _helpers.defineInspectFunc)(RedditContent.prototype, function () {
return this.constructor._name + ' ' + _util2.default.inspect(this._stripPrivateProps());
return "".concat(this.constructor._name, " ").concat(_util.default.inspect(this._stripPrivateProps()));
});
_constants.HTTP_VERBS.forEach(function (method) {
Object.defineProperty(RedditContent.prototype, '_' + method, { value() {
var _r3;
Object.defineProperty(RedditContent.prototype, "_".concat(method), {
value() {
var _this$_r2;
return (_r3 = this._r)['_' + method].apply(_r3, arguments);
}, configurable: true, writable: true });
return (_this$_r2 = this._r)["_".concat(method)].apply(_this$_r2, arguments);
},
configurable: true,
writable: true
});
});
exports.default = RedditContent;
var _default = RedditContent;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,15 +6,18 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _constants = require("../constants.js");
var _constants = require('../constants.js');
var _errors = require("../errors.js");
var _errors = require('../errors.js');
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent = require('./RedditContent.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -29,3 +32,3 @@ * A class representing a reddit user

*/
var RedditUser = class RedditUser extends _RedditContent2.default {
var RedditUser = class RedditUser extends _RedditContent.default {
get _uri() {

@@ -35,3 +38,4 @@ if (typeof this.name !== 'string' || !_constants.USERNAME_REGEX.test(this.name)) {

}
return 'user/' + this.name + '/about';
return "user/".concat(this.name, "/about");
}

@@ -44,2 +48,4 @@ /**

*/
giveGold(months) {

@@ -51,3 +57,9 @@ /* Ideally this would allow for more than 36 months by sending multiple requests, but I don't have the resources to test

}
return this._post({ uri: 'api/v1/gold/give/' + this.name, form: { months } });
return this._post({
uri: "api/v1/gold/give/".concat(this.name),
form: {
months
}
});
}

@@ -63,4 +75,8 @@ /**

*/
assignFlair(options) {
return this._r._assignFlair(_extends({}, options, { name: this.name })).return(this);
return this._r._assignFlair(_objectSpread({}, options, {
name: this.name
})).return(this);
}

@@ -76,2 +92,4 @@ /**

*/
friend() {

@@ -81,3 +99,9 @@ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},

return this._put({ uri: 'api/v1/me/friends/' + this.name, body: { user: this.name, note } }).return(this);
return this._put({
uri: "api/v1/me/friends/".concat(this.name),
body: {
user: this.name,
note
}
}).return(this);
}

@@ -89,4 +113,8 @@ /**

*/
unfriend() {
return this._delete({ uri: 'api/v1/me/friends/' + this.name });
return this._delete({
uri: "api/v1/me/friends/".concat(this.name)
});
}

@@ -101,4 +129,8 @@ /**

*/
getFriendInformation() {
return this._get({ uri: 'api/v1/me/friends/' + this.name });
return this._get({
uri: "api/v1/me/friends/".concat(this.name)
});
}

@@ -117,4 +149,8 @@ /**

*/
getTrophies() {
return this._get({ uri: 'api/v1/user/' + this.name + '/trophies' });
return this._get({
uri: "api/v1/user/".concat(this.name, "/trophies")
});
}

@@ -135,4 +171,9 @@ /**

*/
getOverview(options) {
return this._getListing({ uri: 'user/' + this.name + '/overview', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/overview"),
qs: options
});
}

@@ -153,4 +194,9 @@ /**

*/
getSubmissions(options) {
return this._getListing({ uri: 'user/' + this.name + '/submitted', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/submitted"),
qs: options
});
}

@@ -171,4 +217,9 @@ /**

*/
getComments(options) {
return this._getListing({ uri: 'user/' + this.name + '/comments', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/comments"),
qs: options
});
}

@@ -191,4 +242,9 @@ /**

*/
getUpvotedContent(options) {
return this._getListing({ uri: 'user/' + this.name + '/upvoted', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/upvoted"),
qs: options
});
}

@@ -211,4 +267,9 @@ /**

*/
getDownvotedContent(options) {
return this._getListing({ uri: 'user/' + this.name + '/downvoted', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/downvoted"),
qs: options
});
}

@@ -231,4 +292,9 @@ /**

*/
getHiddenContent(options) {
return this._getListing({ uri: 'user/' + this.name + '/hidden', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/hidden"),
qs: options
});
}

@@ -251,4 +317,9 @@ /**

*/
getSavedContent(options) {
return this._getListing({ uri: 'user/' + this.name + '/saved', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/saved"),
qs: options
});
}

@@ -269,4 +340,9 @@ /**

*/
getGildedContent(options) {
return this._getListing({ uri: 'user/' + this.name + '/gilded', qs: options });
return this._getListing({
uri: "user/".concat(this.name, "/gilded"),
qs: options
});
}

@@ -286,4 +362,9 @@ /**

*/
getMultireddit(name) {
return this._r._newObject('MultiReddit', { name, curator: this });
return this._r._newObject('MultiReddit', {
name,
curator: this
});
}

@@ -304,7 +385,15 @@ /**

*/
getMultireddits() {
return this._get({ uri: 'api/multi/user/' + this.name, qs: { expand_srs: true } });
return this._get({
uri: "api/multi/user/".concat(this.name),
qs: {
expand_srs: true
}
});
}
};
exports.default = RedditUser;
var _default = RedditUser;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,13 +6,11 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _helpers = require('../helpers.js');
var _helpers = require("../helpers.js");
var _RedditContent = require('./RedditContent.js');
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var api_type = 'json';
/**

@@ -23,3 +21,4 @@ * A set of mixin functions that apply to Submissions, Comments, and PrivateMessages

*/
var ReplyableContent = class ReplyableContent extends _RedditContent2.default {
var ReplyableContent = class ReplyableContent extends _RedditContent.default {
/**

@@ -36,5 +35,11 @@ * @summary Removes this Comment, Submission or PrivateMessage from public listings.

_ref$spam = _ref.spam,
spam = _ref$spam === undefined ? false : _ref$spam;
spam = _ref$spam === void 0 ? false : _ref$spam;
return this._post({ uri: 'api/remove', form: { spam, id: this.name } }).return(this);
return this._post({
uri: 'api/remove',
form: {
spam,
id: this.name
}
}).return(this);
}

@@ -46,4 +51,11 @@ /**

*/
approve() {
return this._post({ uri: 'api/approve', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/approve',
form: {
id: this.name
}
}).return(this);
}

@@ -58,2 +70,4 @@ /**

*/
report() {

@@ -63,5 +77,11 @@ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},

return this._post({ uri: 'api/report', form: {
api_type, reason: 'other', other_reason: reason, thing_id: this.name
} }).return(this);
return this._post({
uri: 'api/report',
form: {
api_type,
reason: 'other',
other_reason: reason,
thing_id: this.name
}
}).return(this);
}

@@ -73,4 +93,11 @@ /**

*/
ignoreReports() {
return this._post({ uri: 'api/ignore_reports', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/ignore_reports',
form: {
id: this.name
}
}).return(this);
}

@@ -82,4 +109,11 @@ /**

*/
unignoreReports() {
return this._post({ uri: 'api/unignore_reports', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unignore_reports',
form: {
id: this.name
}
}).return(this);
}

@@ -93,6 +127,12 @@ /**

*/
reply(text) {
return this._post({
uri: 'api/comment',
form: { api_type, text, thing_id: this.name }
form: {
api_type,
text,
thing_id: this.name
}
}).tap((0, _helpers.handleJsonErrors)(this)).then(function (res) {

@@ -114,7 +154,15 @@ return res.json.data.things[0];

*/
blockAuthor() {
return this._post({ uri: 'api/block', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/block',
form: {
id: this.name
}
}).return(this);
}
};
exports.default = ReplyableContent;
var _default = ReplyableContent;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,15 +6,17 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _helpers = require("../helpers.js");
var _helpers = require('../helpers.js');
var _VoteableContent = _interopRequireDefault(require("./VoteableContent.js"));
var _VoteableContent = require('./VoteableContent.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _VoteableContent2 = _interopRequireDefault(_VoteableContent);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var api_type = 'json';
/**

@@ -29,5 +31,7 @@ * A class representing a reddit submission

*/
var Submission = class Submission extends _VoteableContent2.default {
var Submission = class Submission extends _VoteableContent.default {
constructor(data, _r, _hasFetched) {
super(data, _r, _hasFetched);
if (_hasFetched) {

@@ -37,4 +41,5 @@ this.comments = this.comments || (0, _helpers.getEmptyRepliesListing)(this);

}
get _uri() {
return 'comments/' + this.name.slice(3);
return "comments/".concat(this.name.slice(3));
}

@@ -46,4 +51,11 @@ /**

*/
hide() {
return this._post({ uri: 'api/hide', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/hide',
form: {
id: this.name
}
}).return(this);
}

@@ -55,4 +67,11 @@ /**

*/
unhide() {
return this._post({ uri: 'api/unhide', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unhide',
form: {
id: this.name
}
}).return(this);
}

@@ -64,4 +83,11 @@ /**

*/
lock() {
return this._post({ uri: 'api/lock', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/lock',
form: {
id: this.name
}
}).return(this);
}

@@ -73,4 +99,11 @@ /**

*/
unlock() {
return this._post({ uri: 'api/unlock', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unlock',
form: {
id: this.name
}
}).return(this);
}

@@ -82,4 +115,11 @@ /**

*/
markNsfw() {
return this._post({ uri: 'api/marknsfw', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/marknsfw',
form: {
id: this.name
}
}).return(this);
}

@@ -91,4 +131,11 @@ /**

*/
unmarkNsfw() {
return this._post({ uri: 'api/unmarknsfw', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unmarknsfw',
form: {
id: this.name
}
}).return(this);
}

@@ -101,6 +148,12 @@ /**

*/
markSpoiler() {
return this._post({ uri: 'api/spoiler', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/spoiler',
form: {
id: this.name
}
}).return(this);
}
/**

@@ -111,6 +164,12 @@ * @summary Unmark a submission as a spoiler

*/
unmarkSpoiler() {
return this._post({ uri: 'api/unspoiler', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unspoiler',
form: {
id: this.name
}
}).return(this);
}
/**

@@ -122,4 +181,13 @@ * @summary Sets the contest mode status of this submission.

*/
_setContestModeEnabled(state) {
return this._post({ uri: 'api/set_contest_mode', form: { api_type, state, id: this.name } }).return(this);
return this._post({
uri: 'api/set_contest_mode',
form: {
api_type,
state,
id: this.name
}
}).return(this);
}

@@ -131,2 +199,4 @@ /**

*/
enableContestMode() {

@@ -140,10 +210,20 @@ return this._setContestModeEnabled(true);

*/
disableContestMode() {
return this._setContestModeEnabled(false);
}
_setStickied(_ref) {
var state = _ref.state,
num = _ref.num;
return this._post({ uri: 'api/set_subreddit_sticky', form: { api_type, state, num, id: this.name } }).return(this);
return this._post({
uri: 'api/set_subreddit_sticky',
form: {
api_type,
state,
num,
id: this.name
}
}).return(this);
}

@@ -157,8 +237,13 @@ /**

*/
sticky() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$num = _ref2.num,
num = _ref2$num === undefined ? 1 : _ref2$num;
num = _ref2$num === void 0 ? 1 : _ref2$num;
return this._setStickied({ state: true, num });
return this._setStickied({
state: true,
num
});
}

@@ -170,4 +255,8 @@ /**

*/
unsticky() {
return this._setStickied({ state: false });
return this._setStickied({
state: false
});
}

@@ -182,4 +271,13 @@ /**

*/
setSuggestedSort(sort) {
return this._post({ uri: 'api/set_suggested_sort', form: { api_type, id: this.name, sort } }).return(this);
return this._post({
uri: 'api/set_suggested_sort',
form: {
api_type,
id: this.name,
sort
}
}).return(this);
}

@@ -192,4 +290,11 @@ /**

*/
markAsRead() {
return this._post({ uri: 'api/store_visits', form: { links: this.name } }).return(this);
return this._post({
uri: 'api/store_visits',
form: {
links: this.name
}
}).return(this);
}

@@ -202,6 +307,10 @@ /**

*/
getDuplicates() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return this._getListing({ uri: 'duplicates/' + this.name.slice(3), qs: options });
return this._getListing({
uri: "duplicates/".concat(this.name.slice(3)),
qs: options
});
}

@@ -217,2 +326,4 @@ /**

*/
getRelated() {

@@ -222,4 +333,6 @@ var _this = this;

var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return this._getListing({ uri: 'related/' + this.name.slice(3), qs: options }).tap(function (result) {
return this._getListing({
uri: "related/".concat(this.name.slice(3)),
qs: options
}).tap(function (result) {
if (result.constructor._name === 'Submission') {

@@ -243,2 +356,4 @@ _this._r._warn('Submission#getRelated has been deprecated upstream, and will not work as expected.');

*/
getLinkFlairTemplates() {

@@ -259,6 +374,10 @@ var _this2 = this;

*/
assignFlair(options) {
return this._r._assignFlair(_extends({}, options, { link: this.name, subredditName: this.subreddit.display_name })).return(this);
return this._r._assignFlair(_objectSpread({}, options, {
link: this.name,
subredditName: this.subreddit.display_name
})).return(this);
}
/**

@@ -274,6 +393,10 @@ * @summary Selects a flair for this Submission (as the OP; also see [assignFlair]{@link Submission#assignFlair})

*/
selectFlair(options) {
return this._r._selectFlair(_extends({}, options, { link: this.name, subredditName: this.subreddit.display_name })).return(this);
return this._r._selectFlair(_objectSpread({}, options, {
link: this.name,
subredditName: this.subreddit.display_name
})).return(this);
}
/**

@@ -294,7 +417,12 @@ * @summary Crossposts this submission to a different subreddit

*/
submitCrosspost(options) {
return this._r.submitCrosspost(_extends({}, options, { originalPost: this }));
return this._r.submitCrosspost(_objectSpread({}, options, {
originalPost: this
}));
}
};
exports.default = Submission;
var _default = Submission;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,2 +6,4 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
class UserList {

@@ -13,3 +15,5 @@ constructor(options, _r) {

}
}
exports.default = UserList;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _Promise = require('../Promise.js');
var _Promise = _interopRequireDefault(require("../Promise.js"));
var _Promise2 = _interopRequireDefault(_Promise);
var _helpers = require("../helpers.js");
var _helpers = require('../helpers.js');
var _ReplyableContent = _interopRequireDefault(require("./ReplyableContent.js"));
var _ReplyableContent = require('./ReplyableContent.js');
var _ReplyableContent2 = _interopRequireDefault(_ReplyableContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var api_type = 'json';
/**

@@ -27,3 +23,4 @@ * A set of mixin functions that apply to Submissions and Comments.

*/
var VoteableContent = class VoteableContent extends _ReplyableContent2.default {
var VoteableContent = class VoteableContent extends _ReplyableContent.default {
/**

@@ -36,3 +33,9 @@ * @summary Casts a vote on this Comment or Submission.

_vote(direction) {
return this._post({ uri: 'api/vote', form: { dir: direction, id: this.name } }).return(this);
return this._post({
uri: 'api/vote',
form: {
dir: direction,
id: this.name
}
}).return(this);
}

@@ -48,2 +51,4 @@ /**

*/
upvote() {

@@ -61,2 +66,4 @@ return this._vote(1);

*/
downvote() {

@@ -74,2 +81,4 @@ return this._vote(-1);

*/
unvote() {

@@ -83,4 +92,11 @@ return this._vote(0);

*/
save() {
return this._post({ uri: 'api/save', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/save',
form: {
id: this.name
}
}).return(this);
}

@@ -92,4 +108,11 @@ /**

*/
unsave() {
return this._post({ uri: 'api/unsave', form: { id: this.name } }).return(this);
return this._post({
uri: 'api/unsave',
form: {
id: this.name
}
}).return(this);
}

@@ -109,10 +132,14 @@ /**

*/
distinguish() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$status = _ref.status,
status = _ref$status === undefined ? true : _ref$status,
status = _ref$status === void 0 ? true : _ref$status,
_ref$sticky = _ref.sticky,
sticky = _ref$sticky === undefined ? false : _ref$sticky;
sticky = _ref$sticky === void 0 ? false : _ref$sticky;
return this._post({ uri: 'api/distinguish', form: {
return this._post({
uri: 'api/distinguish',
form: {
api_type,

@@ -122,3 +149,4 @@ how: status === true ? 'yes' : status === false ? 'no' : status,

id: this.name
} }).return(this);
}
}).return(this);
}

@@ -130,4 +158,9 @@ /**

*/
undistinguish() {
return this.distinguish({ status: false, sticky: false }).return(this);
return this.distinguish({
status: false,
sticky: false
}).return(this);
}

@@ -140,6 +173,12 @@ /**

*/
edit(updatedText) {
return this._post({
uri: 'api/editusertext',
form: { api_type, text: updatedText, thing_id: this.name }
form: {
api_type,
text: updatedText,
thing_id: this.name
}
}).tap((0, _helpers.handleJsonErrors)(this));

@@ -152,7 +191,18 @@ }

*/
gild() {
return this._post({ uri: 'api/v1/gold/gild/' + this.name }).return(this);
return this._post({
uri: "api/v1/gold/gild/".concat(this.name)
}).return(this);
}
_setInboxRepliesEnabled(state) {
return this._post({ uri: 'api/sendreplies', form: { state, id: this.name } });
return this._post({
uri: 'api/sendreplies',
form: {
state,
id: this.name
}
});
}

@@ -164,2 +214,4 @@ /**

*/
enableInboxReplies() {

@@ -173,5 +225,8 @@ return this._setInboxRepliesEnabled(true).return(this);

*/
disableInboxReplies() {
return this._setInboxRepliesEnabled(false).return(this);
}
_mutateAndExpandReplies(_ref2) {

@@ -184,6 +239,9 @@ var _this = this;

if (depth <= 0) {
return _Promise2.default.resolve(this);
return _Promise.default.resolve(this);
}
var repliesKey = this.constructor._name === 'Submission' ? 'comments' : 'replies';
return this[repliesKey].fetchMore({ amount: limit - this[repliesKey].length }).tap(function (replies) {
return this[repliesKey].fetchMore({
amount: limit - this[repliesKey].length
}).tap(function (replies) {
_this[repliesKey] = replies;

@@ -193,3 +251,6 @@ }).then(function (replies) {

}).map(function (reply) {
return reply._mutateAndExpandReplies({ limit, depth: depth - 1 });
return reply._mutateAndExpandReplies({
limit,
depth: depth - 1
});
}).return(this);

@@ -226,16 +287,23 @@ }

*/
expandReplies() {
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref3$limit = _ref3.limit,
limit = _ref3$limit === undefined ? Infinity : _ref3$limit,
limit = _ref3$limit === void 0 ? Infinity : _ref3$limit,
_ref3$depth = _ref3.depth,
depth = _ref3$depth === undefined ? Infinity : _ref3$depth;
depth = _ref3$depth === void 0 ? Infinity : _ref3$depth;
return this._r._promiseWrap(this.fetch().then(function (result) {
return result._clone({ deep: true })._mutateAndExpandReplies({ limit, depth });
return result._clone({
deep: true
})._mutateAndExpandReplies({
limit,
depth
});
}));
}
};
// VoteableContent#delete is not in the class body since Safari 9 can't parse the `delete` function name in class bodies.
}; // VoteableContent#delete is not in the class body since Safari 9 can't parse the `delete` function name in class bodies.
/**

@@ -250,6 +318,17 @@ * @function

*/
Object.defineProperty(VoteableContent.prototype, 'delete', { value() {
return this._post({ uri: 'api/del', form: { id: this.name } }).return(this);
}, configurable: true, writable: true });
exports.default = VoteableContent;
Object.defineProperty(VoteableContent.prototype, 'delete', {
value() {
return this._post({
uri: 'api/del',
form: {
id: this.name
}
}).return(this);
},
configurable: true,
writable: true
});
var _default = VoteableContent;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _RedditContent = require('./RedditContent.js');
var _RedditContent = _interopRequireDefault(require("./RedditContent.js"));
var _RedditContent2 = _interopRequireDefault(_RedditContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -27,5 +26,5 @@

*/
var WikiPage = class WikiPage extends _RedditContent2.default {
var WikiPage = class WikiPage extends _RedditContent.default {
get _uri() {
return 'r/' + this.subreddit.display_name + '/wiki/' + this.title;
return "r/".concat(this.subreddit.display_name, "/wiki/").concat(this.title);
}

@@ -40,4 +39,8 @@ /**

*/
getSettings() {
return this._get({ uri: 'r/' + this.subreddit.display_name + '/wiki/settings/' + this.title });
return this._get({
uri: "r/".concat(this.subreddit.display_name, "/wiki/settings/").concat(this.title)
});
}

@@ -55,2 +58,4 @@ /**

*/
editSettings(_ref) {

@@ -60,16 +65,21 @@ var listed = _ref.listed,

_ref$permissionLevel = _ref.permissionLevel,
permissionLevel = _ref$permissionLevel === undefined ? permission_level : _ref$permissionLevel;
permissionLevel = _ref$permissionLevel === void 0 ? permission_level : _ref$permissionLevel;
return this._post({
uri: 'r/' + this.subreddit.display_name + '/wiki/settings/' + this.title,
form: { listed, permlevel: permissionLevel }
uri: "r/".concat(this.subreddit.display_name, "/wiki/settings/").concat(this.title),
form: {
listed,
permlevel: permissionLevel
}
}).return(this);
}
_modifyEditor(_ref2) {
var name = _ref2.name,
action = _ref2.action;
return this._post({
uri: 'r/' + this.subreddit.display_name + '/api/wiki/alloweditor/' + action,
form: { page: this.title, username: name }
uri: "r/".concat(this.subreddit.display_name, "/api/wiki/alloweditor/").concat(action),
form: {
page: this.title,
username: name
}
});

@@ -84,6 +94,10 @@ }

*/
addEditor(_ref3) {
var name = _ref3.name;
return this._modifyEditor({ name, action: 'add' }).return(this);
return this._modifyEditor({
name,
action: 'add'
}).return(this);
}

@@ -97,6 +111,10 @@ /**

*/
removeEditor(_ref4) {
var name = _ref4.name;
return this._modifyEditor({ name, action: 'del' }).return(this);
return this._modifyEditor({
name,
action: 'del'
}).return(this);
}

@@ -113,2 +131,4 @@ /**

*/
edit(_ref5) {

@@ -119,7 +139,11 @@ var text = _ref5.text,

_ref5$previousRevisio = _ref5.previousRevision,
previousRevision = _ref5$previousRevisio === undefined ? previous_revision : _ref5$previousRevisio;
previousRevision = _ref5$previousRevisio === void 0 ? previous_revision : _ref5$previousRevisio;
return this._post({
uri: 'r/' + this.subreddit.display_name + '/api/wiki/edit',
form: { content: text, page: this.title, previous: previousRevision, reason }
uri: "r/".concat(this.subreddit.display_name, "/api/wiki/edit"),
form: {
content: text,
page: this.title,
previous: previousRevision,
reason
}
}).return(this);

@@ -144,4 +168,9 @@ }

*/
getRevisions(options) {
return this._getListing({ uri: 'r/' + this.subreddit.display_name + '/wiki/revisions/' + this.title, qs: options });
return this._getListing({
uri: "r/".concat(this.subreddit.display_name, "/wiki/revisions/").concat(this.title),
qs: options
});
}

@@ -155,8 +184,12 @@ /**

*/
hideRevision(_ref6) {
var id = _ref6.id;
return this._post({
uri: 'r/' + this.subreddit.display_name + '/api/wiki/hide',
qs: { page: this.title, revision: id }
uri: "r/".concat(this.subreddit.display_name, "/api/wiki/hide"),
qs: {
page: this.title,
revision: id
}
}).return(this);

@@ -171,8 +204,12 @@ }

*/
revert(_ref7) {
var id = _ref7.id;
return this._post({
uri: 'r/' + this.subreddit.display_name + '/api/wiki/revert',
qs: { page: this.title, revision: id }
uri: "r/".concat(this.subreddit.display_name, "/api/wiki/revert"),
qs: {
page: this.title,
revision: id
}
}).return(this);

@@ -193,7 +230,13 @@ }

*/
getDiscussions(options) {
return this._getListing({ uri: 'r/' + this.subreddit.display_name + '/wiki/discussions/' + this.title, qs: options });
return this._getListing({
uri: "r/".concat(this.subreddit.display_name, "/wiki/discussions/").concat(this.title),
qs: options
});
}
};
exports.default = WikiPage;
var _default = WikiPage;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,11 +6,15 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _bluebird = require('bluebird');
var _bluebird = _interopRequireDefault(require("bluebird"));
var _bluebird2 = _interopRequireDefault(_bluebird);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var PromiseCopy = _bluebird2.default.getNewLibraryCopy();
PromiseCopy.config({ cancellation: true, warnings: false });
exports.default = PromiseCopy;
var PromiseCopy = _bluebird.default.getNewLibraryCopy();
PromiseCopy.config({
cancellation: true,
warnings: false
});
var _default = PromiseCopy;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,12 +6,2 @@ Object.defineProperty(exports, "__esModule", {

});
exports.rawRequest = undefined;
var _merge2 = require('lodash/merge');
var _merge3 = _interopRequireDefault(_merge2);
var _includes2 = require('lodash/includes');
var _includes3 = _interopRequireDefault(_includes2);
exports.oauthRequest = oauthRequest;

@@ -24,15 +14,22 @@ exports._awaitExponentialBackoff = _awaitExponentialBackoff;

exports.updateAccessToken = updateAccessToken;
exports.rawRequest = void 0;
var _Promise = require('./Promise.js');
var _lodash = require("lodash");
var _Promise2 = _interopRequireDefault(_Promise);
var _Promise = _interopRequireDefault(require("./Promise.js"));
var _constants = require('./constants.js');
var _constants = require("./constants.js");
var _errors = require('./errors.js');
var _errors = require("./errors.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
/**

@@ -81,4 +78,3 @@ * @summary Sends an oauth-authenticated request to the reddit server, and returns the server's response.

var attempts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return (_Promise$resolve$then = _Promise2.default.resolve().then(function () {
return (_Promise$resolve$then = _Promise.default.resolve().then(function () {
return _this._awaitRatelimit();

@@ -92,8 +88,14 @@ }).then(function () {

}).then(function (token) {
return _this.rawRequest((0, _merge3.default)({
return _this.rawRequest((0, _lodash.merge)({
json: true,
headers: { 'user-agent': _this.userAgent },
baseUrl: 'https://oauth.' + _this._config.endpointDomain,
qs: { raw_json: 1 },
auth: { bearer: token },
headers: {
'user-agent': _this.userAgent
},
baseUrl: "https://oauth.".concat(_this._config.endpointDomain),
qs: {
raw_json: 1
},
auth: {
bearer: token
},
resolveWithFullResponse: true,

@@ -106,3 +108,5 @@ timeout: _this._config.requestTimeout,

}
_this._debug('Received a ' + response.statusCode + ' status code from a `' + response.request.method + '` request', 'sent to ' + response.request.uri.href + '. ratelimitRemaining: ' + _this.ratelimitRemaining);
_this._debug("Received a ".concat(response.statusCode, " status code from a `").concat(response.request.method, "` request"), "sent to ".concat(response.request.uri.href, ". ratelimitRemaining: ").concat(_this.ratelimitRemaining));
return response;

@@ -113,10 +117,14 @@ }

var populated = _this._populate(response.body);
if (populated && populated.constructor._name === 'Listing') {
populated._setUri(response.request.uri.href);
}
return populated;
})).catch.apply(_Promise$resolve$then, _toConsumableArray(this._config.retryErrorCodes.map(function (retryCode) {
return { statusCode: retryCode };
return {
statusCode: retryCode
};
})).concat([function (e) {
if (!(0, _includes3.default)(_constants.IDEMPOTENT_HTTP_VERBS, e.response.request.method) || attempts >= _this._config.maxRetryAttempts) {
if (!(0, _lodash.includes)(_constants.IDEMPOTENT_HTTP_VERBS, e.response.request.method) || attempts >= _this._config.maxRetryAttempts) {
throw e;

@@ -126,5 +134,10 @@ }

remaining, retry this request and increment the `attempts` counter. */
_this._warn('Received status code ' + e.statusCode + ' from reddit.', 'Retrying request (attempt ' + (attempts + 1) + '/' + _this._config.maxRetryAttempts + ')...');
_this._warn("Received status code ".concat(e.statusCode, " from reddit."), "Retrying request (attempt ".concat(attempts + 1, "/").concat(_this._config.maxRetryAttempts, ")..."));
return _this.oauthRequest(options, attempts + 1);
}])).catch({ statusCode: 401 }, function (e) {
}])).catch({
statusCode: 401
}, function (e) {
/* If the server returns a 401 error, it's possible that the access token expired during the latency period as this

@@ -139,2 +152,3 @@ request was being sent. In this scenario, snoowrap thought that the access token was valid for a few more seconds, so it

}
throw e;

@@ -146,6 +160,6 @@ });

if (attempts === 1) {
return _Promise2.default.resolve();
return _Promise.default.resolve();
}
return _Promise2.default.delay((Math.pow(2, attempts - 1) + (Math.random() - 0.3)) * 1000);
return _Promise.default.delay((Math.pow(2, attempts - 1) + (Math.random() - 0.3)) * 1000);
}

@@ -157,2 +171,3 @@

var timeUntilExpiry = this.ratelimitExpiration - Date.now();
if (this._config.continueAfterRatelimitError) {

@@ -162,9 +177,12 @@ /* If the `continue_after_ratelimit_error` setting is enabled, queue the request, wait until the next ratelimit

this._warn((0, _errors.rateLimitWarning)(timeUntilExpiry));
return _Promise2.default.delay(timeUntilExpiry);
}
// Otherwise, throw an error.
return _Promise.default.delay(timeUntilExpiry);
} // Otherwise, throw an error.
throw new _errors.RateLimitError(timeUntilExpiry);
}
// If the ratelimit hasn't been exceeded, no delay is necessary.
return _Promise2.default.resolve();
} // If the ratelimit hasn't been exceeded, no delay is necessary.
return _Promise.default.resolve();
}

@@ -176,5 +194,4 @@

this._nextRequestTimestamp = Math.max(now, this._nextRequestTimestamp) + this._config.requestDelay;
return _Promise2.default.delay(waitTime);
return _Promise.default.delay(waitTime);
}
/**

@@ -208,12 +225,18 @@ * @summary Sends a request to the reddit server, authenticated with the user's client ID and client secret.

*/
function credentialedClientRequest(options) {
var requestFunc = this.rawRequest || rawRequest;
return _Promise2.default.resolve(requestFunc.call(this, (0, _merge3.default)({
return _Promise.default.resolve(requestFunc.call(this, (0, _lodash.merge)({
json: true,
auth: { user: this.clientId || this.client_id || '', pass: this.clientSecret || this.client_secret || '' },
headers: { 'user-agent': this.userAgent },
baseUrl: this._config ? 'https://www.' + this._config.endpointDomain : undefined
auth: {
user: this.clientId || this.client_id || '',
pass: this.clientSecret || this.client_secret || ''
},
headers: {
'user-agent': this.userAgent
},
baseUrl: this._config ? "https://www.".concat(this._config.endpointDomain) : undefined
}, options)));
}
/**

@@ -227,10 +250,13 @@ * @summary Sends a request to the reddit server without authentication.

*/
function unauthenticatedRequest(options) {
return _Promise2.default.resolve(this.rawRequest((0, _merge3.default)({
return _Promise.default.resolve(this.rawRequest((0, _lodash.merge)({
json: true,
headers: { 'user-agent': this.userAgent },
baseUrl: 'https://www.' + this._config.endpointDomain
headers: {
'user-agent': this.userAgent
},
baseUrl: "https://www.".concat(this._config.endpointDomain)
}, options)));
}
/**

@@ -245,2 +271,4 @@ * @summary Updates this requester's access token if the current one is absent or expired.

*/
function updateAccessToken() {

@@ -254,21 +282,30 @@ var _this2 = this;

uri: 'api/v1/access_token',
form: this.refreshToken ? { grant_type: 'refresh_token', refresh_token: this.refreshToken } : { grant_type: 'password', username: this.username, password: this.password }
form: this.refreshToken ? {
grant_type: 'refresh_token',
refresh_token: this.refreshToken
} : {
grant_type: 'password',
username: this.username,
password: this.password
}
}).then(function (tokenInfo) {
_this2.accessToken = tokenInfo.access_token;
_this2.tokenExpiration = Date.now() + tokenInfo.expires_in * 1000;
if (tokenInfo.error === 'invalid_grant') {
throw new Error('"Invalid grant" error returned from reddit. (You might have incorrect credentials.)');
} else if (tokenInfo.error_description !== undefined) {
throw new Error('Reddit returned an error: ' + tokenInfo.error + ': ' + tokenInfo.error_description);
throw new Error("Reddit returned an error: ".concat(tokenInfo.error, ": ").concat(tokenInfo.error_description));
} else if (tokenInfo.error !== undefined) {
throw new Error('Reddit returned an error: ' + tokenInfo.error);
throw new Error("Reddit returned an error: ".concat(tokenInfo.error));
}
_this2.scope = tokenInfo.scope.split(' ');
return _this2.accessToken;
});
}
// Otherwise, just return the existing token.
return _Promise2.default.resolve(this.accessToken);
} // Otherwise, just return the existing token.
return _Promise.default.resolve(this.accessToken);
}
/**

@@ -340,2 +377,7 @@ * @function

*/
var rawRequest = exports.rawRequest = typeof XMLHttpRequest !== 'undefined' ? require('./xhr') : require('request-promise').defaults({ gzip: true });
var rawRequest = typeof XMLHttpRequest !== 'undefined' ? require('./xhr') : require('request-promise').defaults({
gzip: true
});
exports.rawRequest = rawRequest;

@@ -1,17 +0,14 @@

'use strict';
"use strict";
var _Promise = require('./Promise.js');
var _Promise = _interopRequireDefault(require("./Promise.js"));
var _Promise2 = _interopRequireDefault(_Promise);
var _url = _interopRequireDefault(require("url"));
var _url = require('url');
var _querystring = require("querystring");
var _url2 = _interopRequireDefault(_url);
var _errors = require("./errors.js");
var _querystring = require('querystring');
var _errors = require('./errors.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-env browser */
// Provide a shim for some of the functionality of the `request-promise` npm package in browsers.

@@ -21,4 +18,2 @@ // Previously, snoowrap depended on browserify to package `request-promise` for the browser bundle, and while this worked

// doesn't actually need.
/* eslint-env browser */
function noop() {}

@@ -46,6 +41,8 @@

// It would be nice to be able to use the `URL` API in browsers, but Safari 9 doesn't support `URLSearchParams`.
var parsedUrl = _url2.default.parse(options.url || _url2.default.resolve(options.baseUrl, options.uri), true);
parsedUrl.search = (0, _querystring.stringify)(Object.assign({}, parsedUrl.query, options.qs));
// create a new url object with the new qs params, to ensure that the `href` value changes (to use later for parsing response)
var finalUrl = _url2.default.parse(parsedUrl.format());
var parsedUrl = _url.default.parse(options.url || _url.default.resolve(options.baseUrl, options.uri), true);
parsedUrl.search = (0, _querystring.stringify)(Object.assign({}, parsedUrl.query, options.qs)); // create a new url object with the new qs params, to ensure that the `href` value changes (to use later for parsing response)
var finalUrl = _url.default.parse(parsedUrl.format());
var xhr = new XMLHttpRequest();

@@ -59,7 +56,9 @@ var method = options.method ? options.method.toUpperCase() : 'GET';

});
if (options.auth) {
xhr.setRequestHeader('Authorization', options.auth.bearer ? 'bearer ' + options.auth.bearer : 'basic ' + btoa(options.auth.user + ':' + options.auth.pass));
xhr.setRequestHeader('Authorization', options.auth.bearer ? "bearer ".concat(options.auth.bearer) : 'basic ' + btoa("".concat(options.auth.user, ":").concat(options.auth.pass)));
}
var requestBody = void 0;
var requestBody;
if (options.formData) {

@@ -70,2 +69,3 @@ requestBody = new FormData();

});
if (options.form) {

@@ -76,2 +76,3 @@ Object.keys(options.form).forEach(function (key) {

}
xhr.setRequestHeader('Content-Type', 'multipart/form-data');

@@ -88,6 +89,7 @@ } else if (options.form) {

return new _Promise2.default(function (resolve, reject, onCancel) {
return new _Promise.default(function (resolve, reject, onCancel) {
onCancel(function () {
return xhr.abort();
});
xhr.onload = function () {

@@ -104,4 +106,8 @@ var _this = this;

headers: parseHeaders(xhr.getAllResponseHeaders()),
request: { method, uri: finalUrl }
request: {
method,
uri: finalUrl
}
};
if (typeof options.transform === 'function') {

@@ -115,7 +121,9 @@ settleFunc(options.transform(response.body, response));

};
xhr.onerror = function (err) {
return reject(Object.assign(new _errors.RequestError(), err));
};
xhr.send(requestBody);
}).timeout(options.timeout || Math.pow(2, 31) - 1, 'Error: ETIMEDOUT').catch(_Promise2.default.TimeoutError, function (err) {
}).timeout(options.timeout || Math.pow(2, 31) - 1, 'Error: ETIMEDOUT').catch(_Promise.default.TimeoutError, function (err) {
xhr.abort();

@@ -122,0 +130,0 @@ throw err;

{
"name": "snoowrap",
"version": "1.18.0",
"version": "1.19.0",
"license": "MIT",
"description": "A JavaScript wrapper for the reddit API",
"main": "dist/snoowrap.js",
"types": "dist/snoowrap.d.ts",
"scripts": {
"prepublishOnly": "npm run compile",
"compile": "babel -q -d dist/ src/",
"compile": "npm run type-check && npm run build:babel && npm run build:types && node ./scripts/copyTSTypes.js",
"lint": "eslint --ignore-path .gitignore . --cache",
"test": "npm run lint && npm run test:mocha",
"test:mocha": "npm run compile && mocha --compilers js:babel-core/register test/snoowrap.spec.js",
"test:mocha": "npm run compile && mocha --require @babel/register test/snoowrap.spec.js",
"test:browser": "npm run compile && browserify --im test/snoowrap.spec.js -o test/_browser.spec.js -t [ babelify ] && open test/run-tests.html",
"smoketest": "npm run test -- -g 'smoketest'",
"build-docs": "scripts/build_docs.sh",
"build:babel": "babel -q -d dist/ src/",
"build:types": "tsc -p tsconfig.gen-dts.json",
"bundle-size": "npm run build-docs && gzip -c doc/snoowrap-v$(npm info . version).min.js | wc -c | xargs",
"coverage": "istanbul cover _mocha -- --compilers js:babel-core/register test/snoowrap.spec.js"
"coverage": "istanbul cover _mocha -- --require @babel/register test/snoowrap.spec.js",
"type-check": "tsc -p tsconfig.typecheck.json"
},

@@ -39,4 +43,4 @@ "files": [

"dependencies": {
"bluebird": "^3.4.1",
"lodash": "^4.5.1",
"bluebird": "^3.5.5",
"lodash": "^4.17.15",
"promise-chains": "^0.3.11",

@@ -48,13 +52,18 @@ "request": "^2.87.0",

"devDependencies": {
"babel-cli": "^6.14.0",
"babel-plugin-lodash": "^3.2.6",
"babel-plugin-transform-async-to-generator": "^6.8.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0",
"babel-plugin-transform-es2015-block-scoping": "^6.14.0",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.14.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-spread": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-arrow-functions": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.0.0",
"@babel/plugin-transform-block-scoping": "^7.0.0",
"@babel/plugin-transform-destructuring": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/plugin-transform-parameters": "^7.0.0",
"@babel/plugin-transform-spread": "^7.0.0",
"@babel/plugin-transform-template-literals": "^7.0.0",
"@babel/plugin-transform-typescript": "^7.0.0",
"@babel/register": "^7.5.5",
"@types/request": "^2.48.2",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"babelify": "^7.3.0",

@@ -64,11 +73,13 @@ "browserify": "^13.1.0",

"dirty-chai": "^1.2.2",
"eslint": "^3.9.1",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-promise": "^3.3.0",
"eslint": "^6.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-promise": "^4.2.1",
"fs-extra": "^8.1.0",
"ink-docstrap": "^1.2.1",
"istanbul": "^1.0.0-alpha.2",
"jsdoc": "^3.4.0",
"mocha": "^3.0.2",
"jsdoc": "^3.6.3",
"mocha": "^6.0.0",
"moment": "^2.14.1",
"uglify-js": "git://github.com/mishoo/UglifyJS2/#1db50c3b169ee4195e1935013d6721628eb5b4bd"
"typescript": "^3.5.3",
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#1db50c3b169ee4195e1935013d6721628eb5b4bd"
},

@@ -75,0 +86,0 @@ "engines": {

@@ -184,3 +184,3 @@ # snoowrap [![Build Status](https://travis-ci.org/not-an-aardvark/snoowrap.svg?branch=master)](https://travis-ci.org/not-an-aardvark/snoowrap) [![Gitter chat](https://badges.gitter.im/not-an-aardvark/snoowrap.svg)](https://gitter.im/not-an-aardvark/snoowrap 'Join the chat at https://gitter.im/not-an-aardvark/snoowrap')

* [snoowrap-v1.js](https://not-an-aardvark.github.io/snoowrap/snoowrap-v1.js)
* [snoowrap-v1.min.js](https://not-an-aardvark.github.io/snoowrap/snoowrap-v1.min.js) (82kB gzipped)
* [snoowrap-v1.min.js](https://not-an-aardvark.github.io/snoowrap/snoowrap-v1.min.js) (89kB gzipped)

@@ -187,0 +187,0 @@ These files will occasionally be updated as new versions of snoowrap 1 are released. Since snoowrap follows semantic versioning, the changes should not break your code. However, if you would prefer to pin the version, you can specify a version number in the URL (e.g. [snoowrap-v1.11.3.min.js](https://not-an-aardvark.github.io/snoowrap/snoowrap-v1.11.3.min.js)). For a list of all available prebuilt versions, see the [gh-pages branch](https://github.com/not-an-aardvark/snoowrap/tree/gh-pages) of this repository.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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