content-entry
Advanced tools
Comparing version 1.7.1 to 1.8.0
@@ -143,2 +143,4 @@ 'use strict'; | ||
* Content entries where a buffer is the primary data representation | ||
* @property {Buffer} buffer | ||
* | ||
*/ | ||
@@ -188,2 +190,3 @@ function BufferContentEntryMixin(superclass) { | ||
} | ||
async setString(value, options) { | ||
@@ -219,2 +222,51 @@ const stream$$1 = await this.getWriteStream(options); | ||
/** | ||
* Content entries where a string is the primary data representation | ||
* @property {string} string | ||
* | ||
*/ | ||
function StringContentEntryMixin(superclass) { | ||
return class StringContentEntryMixin extends superclass { | ||
get encoding() { | ||
return "utf8"; | ||
} | ||
/** | ||
* Deliver content as string | ||
* @return {string} content | ||
*/ | ||
async getString() { | ||
return this.string; | ||
} | ||
async getBuffer() { | ||
return new Buffer.from(this.string, this.encoding); | ||
} | ||
/** | ||
* Deliver content as read stream | ||
* @return {ReadableStream} content | ||
*/ | ||
async getReadStream() { | ||
return toReadableStream(this.string); | ||
} | ||
}; | ||
} | ||
/** | ||
* Content entries where a string is the primary data representation | ||
* | ||
* @param {string} name | ||
* @param {string} value | ||
* | ||
* @property {string} name | ||
* @property {string} string | ||
*/ | ||
class StringContentEntry extends StringContentEntryMixin(ContentEntry) { | ||
constructor(name, value) { | ||
super(name); | ||
Object.defineProperties(this, { string: { value } }); | ||
} | ||
} | ||
/** | ||
* Representation of one file or directory entry | ||
@@ -361,2 +413,4 @@ * All names are asolute (no leading '/') and build with '/' | ||
exports.StreamContentEntryMixin = StreamContentEntryMixin; | ||
exports.StringContentEntryMixin = StringContentEntryMixin; | ||
exports.StringContentEntry = StringContentEntry; | ||
exports.BaseEntry = BaseEntry; | ||
@@ -363,0 +417,0 @@ exports.BaseCollectionEntry = BaseCollectionEntry; |
{ | ||
"name": "content-entry", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"publishConfig": { | ||
@@ -39,11 +39,11 @@ "access": "public" | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-cleanup": "^3.0.0", | ||
"rollup-plugin-cleanup": "^3.1.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-json": "^3.1.0", | ||
"rollup-plugin-executable": "^1.3.0", | ||
"semantic-release": "^15.13.1", | ||
"semantic-release": "^15.13.2", | ||
"travis-deploy-once": "^5.0.11" | ||
}, | ||
"engines": { | ||
"node": ">=10.14.2" | ||
"node": ">=10.15.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "repository": { |
@@ -47,4 +47,11 @@ [![npm](https://img.shields.io/npm/v/content-entry.svg)](https://www.npmjs.com/package/content-entry) | ||
- [Parameters](#parameters-7) | ||
- [Properties](#properties-2) | ||
- [StreamContentEntryMixin](#streamcontententrymixin) | ||
- [Parameters](#parameters-8) | ||
- [StringContentEntryMixin](#stringcontententrymixin) | ||
- [Parameters](#parameters-9) | ||
- [Properties](#properties-3) | ||
- [StringContentEntry](#stringcontententry) | ||
- [Parameters](#parameters-10) | ||
- [Properties](#properties-4) | ||
@@ -171,2 +178,6 @@ ## Entry | ||
### Properties | ||
- `buffer` **[Buffer](https://nodejs.org/api/buffer.html)** | ||
## StreamContentEntryMixin | ||
@@ -179,1 +190,29 @@ | ||
- `superclass` | ||
## StringContentEntryMixin | ||
Content entries where a string is the primary data representation | ||
### Parameters | ||
- `superclass` | ||
### Properties | ||
- `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## StringContentEntry | ||
**Extends StringContentEntryMixin(ContentEntry)** | ||
Content entries where a string is the primary data representation | ||
### Parameters | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
### Properties | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** |
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
30533
14
745
216