content-entry
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -12,5 +12,5 @@ 'use strict'; | ||
* All names are asolute (no leading '/') and build with '/' | ||
* @property {string} name file name inside of the repository | ||
* @property {string} name name inside of the container | ||
* | ||
* @param {string} name file name inside of the repository | ||
* @param {string} name name inside of the container | ||
*/ | ||
@@ -84,19 +84,61 @@ class BaseEntry { | ||
*/ | ||
function ContentEntryMixin(superclass) { | ||
return class ContentEntryMixin extends superclass { | ||
get isBlob() { | ||
return true; | ||
} | ||
class ContentEntry extends BaseEntry { | ||
get isBlob() { | ||
return true; | ||
} | ||
async getReadStream() { | ||
return undefined; | ||
async getReadStream() { | ||
return undefined; | ||
} | ||
async getString() { | ||
return undefined; | ||
} | ||
async getBuffer() { | ||
return undefined; | ||
} | ||
} | ||
/** | ||
* represents a entry without content (content length = 0) | ||
*/ | ||
class EmptyContentEntry extends ContentEntry { | ||
async getString() { | ||
return ""; | ||
} | ||
async getBuffer() { | ||
return Buffer.alloc(0); | ||
} | ||
} | ||
/** | ||
* Content entries where a buffer is the primary data representation | ||
*/ | ||
function BufferContentEntryMixin(superclass) { | ||
return class BufferContentEntryMixin extends superclass { | ||
get encoding() { | ||
return "utf8"; | ||
} | ||
/** | ||
* Deliver content as string | ||
* @return {string} content | ||
*/ | ||
async getString() { | ||
return undefined; | ||
return this.buffer.toString(this.encoding); | ||
} | ||
async getBuffer() { | ||
return undefined; | ||
return this.buffer; | ||
} | ||
/** | ||
* Deliver content as read stream | ||
* @return {ReadableStream} content | ||
*/ | ||
async getReadStream() { | ||
return toReadableStream(this.buffer); | ||
} | ||
}; | ||
@@ -106,13 +148,17 @@ } | ||
/** | ||
* represents a entry without content (content length = 0) | ||
* Content entries where a stream is the primary data representation | ||
*/ | ||
class EmptyContentEntry extends ContentEntryMixin(BaseEntry) { | ||
function StreamContentEntryMixin(superclass) { | ||
return class StreamContentEntryMixin extends superclass { | ||
async getString(options) { | ||
const stream$$1 = await this.getReadStream(options); | ||
async getString() { | ||
return ""; | ||
} | ||
let value = ""; | ||
for await (chunk of stream$$1) { | ||
value += chunk; | ||
} | ||
async getBuffer() { | ||
return Buffer.alloc(0); | ||
return value; | ||
} | ||
}; | ||
} | ||
@@ -260,2 +306,4 @@ | ||
exports.BufferContentEntryMixin = BufferContentEntryMixin; | ||
exports.StreamContentEntryMixin = StreamContentEntryMixin; | ||
exports.BaseEntry = BaseEntry; | ||
@@ -262,0 +310,0 @@ exports.BaseCollectionEntry = BaseCollectionEntry; |
{ | ||
"name": "content-entry", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"publishConfig": { | ||
@@ -32,3 +32,3 @@ "access": "public" | ||
"devDependencies": { | ||
"documentation": "^9.0.0", | ||
"documentation": "^9.1.1", | ||
"markdown-doctest": "^0.9.1", | ||
@@ -38,3 +38,3 @@ "ava": "^1.0.1", | ||
"esm": "^3.0.84", | ||
"rollup": "^0.68.0", | ||
"rollup": "^0.68.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
@@ -41,0 +41,0 @@ "rollup-plugin-cleanup": "^3.0.0", |
@@ -42,4 +42,7 @@ [![npm](https://img.shields.io/npm/v/content-entry.svg)](https://www.npmjs.com/package/content-entry) | ||
- [EmptyContentEntry](#emptycontententry) | ||
- [ContentEntryMixin](#contententrymixin) | ||
- [ContentEntry](#contententry) | ||
- [BufferContentEntryMixin](#buffercontententrymixin) | ||
- [Parameters](#parameters-6) | ||
- [StreamContentEntryMixin](#streamcontententrymixin) | ||
- [Parameters](#parameters-7) | ||
@@ -118,7 +121,7 @@ ## Entry | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file name inside of the repository | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name inside of the container | ||
### Properties | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file name inside of the repository | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name inside of the container | ||
@@ -139,12 +142,26 @@ ### getTypes | ||
**Extends ContentEntryMixin(BaseEntry)** | ||
**Extends ContentEntry** | ||
represents a entry without content (content length = 0) | ||
## ContentEntryMixin | ||
## ContentEntry | ||
**Extends BaseEntry** | ||
general content access entries | ||
## BufferContentEntryMixin | ||
Content entries where a buffer is the primary data representation | ||
### Parameters | ||
- `superclass` | ||
## StreamContentEntryMixin | ||
Content entries where a stream is the primary data representation | ||
### Parameters | ||
- `superclass` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23596
550
165