Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function wrapper (/* arguments */) {
try {
const result = f.apply(null, arguments)
if (isPromise(result)) {
return new Task((reject, resolve) => result.then(resolve, reject))
} else if (isTask(result)) {
return result
} else {
return Task.of(result)
}
} catch (error) {
return Task.rejected(error)
}
},
Array.prototype.slice.call(arguments)
it('fetches a comment page without a pageToken', function () {
var videoId = 'abc1234'
var commentPage = { comment: 'page' }
var fetchCommentsTask = td.replace('../lib/youtube-comments-task-wrapper')
var fetchComments = require('../lib/fetch-comments')
td.when(fetchCommentsTask(videoId), { ignoreExtraArgs: true })
.thenReturn(Task.of(commentPage))
return fetchComments(videoId)
.then(function (p) {
expect(p).to.deep.equal(commentPage)
})
})
const setTodos = todos =>
Task.of(JSON.stringify(todos))
.chain(str => setItem('todos', str))
.map(() => todos)
const getRef = () =>
Task.of(path.resolve(__dirname, 'snap.json'))
.chain(filepath => statOrDownload(snapUrl(branch), filepath))
.chain(readFile);
({ replies, nextRepliesToken }) =>
(nextRepliesToken
? fetchAllReplies(videoId, nextRepliesToken).map(nextReplies =>
replies.concat(nextReplies)
)
: Task.of(replies))
)