Skip to content

Commit

Permalink
fix: inline is-array-buffer for webpack compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wyvern8 authored and gr2m committed Mar 2, 2018
1 parent ce9c892 commit 42544b2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions lib/request/is-array-buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*!
* isArrayBuffer v1.0.0
* https://github.com/fengyuanchen/is-array-buffer
*
* Copyright (c) 2015-2017 Chen Fengyuan
* Released under the MIT license
*
* Date: 2017-07-26T11:00:44.931Z
*/

'use strict'

// temporary workaround for https://github.com/octokit/rest.js/issues/774

const hasArrayBuffer = typeof ArrayBuffer === 'function'
const toString = Object.prototype.toString

/**
* Check if the given value is an ArrayBuffer.
* @param {*} value - The value to check.
* @returns {boolean} Returns `true` if the given is an ArrayBuffer, else `false`.
* @example
* isArrayBuffer(new ArrayBuffer())
* // => true
* isArrayBuffer(new Array())
* // => false
*/
function isArrayBuffer (value) {
return hasArrayBuffer && (value instanceof ArrayBuffer || toString.call(value) === '[object ArrayBuffer]')
}

module.exports = isArrayBuffer
2 changes: 1 addition & 1 deletion lib/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const https = require('https')

const debug = require('debug')('octokit:rest')
const defaults = require('lodash/defaults')
const isArrayBuffer = require('is-array-buffer')
const isStream = require('is-stream')
const pick = require('lodash/pick')

const HttpError = require('./http-error')
const isArrayBuffer = require('./is-array-buffer')

function httpRequest (origRequestOptions) {
const requestOptions = Object.assign(
Expand Down

0 comments on commit 42544b2

Please sign in to comment.