Socket
Socket
Sign inDemoInstall

array-source

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-source - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

cancel.js

10

dist/array-source.js

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

// https://github.com/mbostock/array-source Version 0.0.1. Copyright 2016 Mike Bostock.
// https://github.com/mbostock/array-source Version 0.0.2. Copyright 2016 Mike Bostock.
(function (global, factory) {

@@ -19,2 +19,6 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

function array(array) {
return new ArraySource(array instanceof ArrayBuffer ? new Uint8Array(array) : array);
}
function ArraySource(array) {

@@ -27,8 +31,4 @@ this._array = array;

function array(array) {
return new ArraySource(array instanceof ArrayBuffer ? new Uint8Array(array) : array);
}
return array;
})));

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

// https://github.com/mbostock/array-source Version 0.0.1. Copyright 2016 Mike Bostock.
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e.sources=e.sources||{},e.sources.array=r())}(this,function(){"use strict";function e(){return this._array=null,Promise.resolve()}function r(){var e=this._array;return this._array=null,Promise.resolve(e?{done:!1,value:e}:{done:!0,value:void 0})}function n(e){this._array=e}function o(e){return new n(e instanceof ArrayBuffer?new Uint8Array(e):e)}return n.prototype.read=r,n.prototype.cancel=e,o});
// https://github.com/mbostock/array-source Version 0.0.2. Copyright 2016 Mike Bostock.
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e.sources=e.sources||{},e.sources.array=r())}(this,function(){"use strict";function e(){return this._array=null,Promise.resolve()}function r(){var e=this._array;return this._array=null,Promise.resolve(e?{done:!1,value:e}:{done:!0,value:void 0})}function n(e){return new o(e instanceof ArrayBuffer?new Uint8Array(e):e)}function o(e){this._array=e}return o.prototype.read=r,o.prototype.cancel=e,n});

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

import ArraySource from "./array/index";
import array_cancel from "./cancel";
import array_read from "./read";

@@ -6,1 +7,8 @@ export default function array(array) {

}
function ArraySource(array) {
this._array = array;
}
ArraySource.prototype.read = array_read;
ArraySource.prototype.cancel = array_cancel;
{
"name": "array-source",
"version": "0.0.1",
"version": "0.0.2",
"description": "Read arrays as standard WhatWG streams.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,32 +0,13 @@

# slice-source
# array-source
A [readable stream reader](https://streams.spec.whatwg.org/#readable-stream-reader) that takes a *length* argument, allowing you to pull the specified number of bytes from the underlying readable stream. For example:
A [readable stream reader](https://streams.spec.whatwg.org/#readable-stream-reader) for reading from an in-memory array.
```html
<!DOCTYPE html>
<script src="https://unpkg.com/slice-source@0"></script>
<script>
fetch("https://cors-anywhere.herokuapp.com/").then((response) => {
return (function read(reader) {
return reader.read(40).then((result) => {
if (result.done) return;
console.log(result.value);
return read(reader);
});
})(sources.slice(response.body));
}).catch((error) => console.error(error.stack));
</script>
```
## API Reference
<a name="slice" href="#slice">#</a> <b>slice</b>(<i>stream</i>) [<>](https://github.com/mbostock/slice-source/blob/master/index.js#L4 "Source")
<br><a href="#slice">#</a> <b>slice</b>(<i>buffer</i>)
<a name="array" href="#array">#</a> <b>array</b>(<i>buffer</i>) [<>](https://github.com/mbostock/array-source/blob/master/index.js#L4 "Source")
<br><a href="#slice">#</a> <b>slice</b>(<i>array</i>)
Returns a sliceable *source* for the specified [readable *stream*](https://streams.spec.whatwg.org/#rs). The *source* may also be specified as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) for reading from something that is already in-memory.
Returns a sliceable *source* for the specified [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
<a name="source_read" href="#source_read">#</a> <i>source</i>.<b>read</b>(<i>length</i>) [<>](https://github.com/mbostock/slice-source/blob/master/slice/read.js "Source")
<a name="source_read" href="#source_read">#</a> <i>source</i>.<b>read</b>() [<>](https://github.com/mbostock/array-source/blob/master/slice/read.js "Source")

@@ -38,6 +19,4 @@ Returns a Promise for the next chunk of data from the underlying stream. The yielded result is an object with the following properties:

The promise will be yielded with a *value* of *length* bytes, or the remaining bytes of the underlying stream if the underlying stream has more than zero but fewer than *length* bytes remaining. When no bytes remain in the stream, the yielded *value* will be undefined, and *done* will be true.
<a name="source_cancel" href="#source_cancel">#</a> <i>source</i>.<b>cancel</b>() [<>](https://github.com/mbostock/array-source/blob/master/slice/cancel.js "Source")
<a name="source_cancel" href="#source_cancel">#</a> <i>source</i>.<b>cancel</b>() [<>](https://github.com/mbostock/slice-source/blob/master/slice/cancel.js "Source")
Returns a Promise which is resolved when the underlying stream has been destroyed.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc