Comparing version 5.1.0 to 5.2.0
# Changelog | ||
## [5.2.0](https://www.github.com/image-js/iobuffer/compare/v5.1.0...v5.2.0) (2022-10-04) | ||
### Features | ||
* add IOBuffer.back() ([#52](https://www.github.com/image-js/iobuffer/issues/52)) ([49a2df9](https://www.github.com/image-js/iobuffer/commit/49a2df924ac512d96d394eecb7fe24fdd2469ead)) | ||
* decode text ([616b1a5](https://www.github.com/image-js/iobuffer/commit/616b1a5e841ceb1174a86c6eb87bcffe571aca2f)) | ||
## [5.1.0](https://www.github.com/image-js/iobuffer/compare/v5.0.4...v5.1.0) (2021-12-17) | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { decode, encode } from './utf8'; | ||
import { decode, encode } from './text'; | ||
const defaultByteLength = 1024 * 8; | ||
@@ -93,2 +93,10 @@ export class IOBuffer { | ||
/** | ||
* Move the pointer n bytes backward. | ||
* @param n - Number of bytes to move back. | ||
*/ | ||
back(n = 1) { | ||
this.offset -= n; | ||
return this; | ||
} | ||
/** | ||
* Move the pointer to the given offset. | ||
@@ -287,2 +295,10 @@ * @param offset | ||
/** | ||
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer | ||
* forward by `n` bytes. | ||
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8} | ||
*/ | ||
decodeText(n = 1, encoding = 'utf-8') { | ||
return decode(this.readBytes(n), encoding); | ||
} | ||
/** | ||
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer | ||
@@ -289,0 +305,0 @@ * forward by 1 byte. |
@@ -76,2 +76,7 @@ /// <reference types="node" /> | ||
/** | ||
* Move the pointer n bytes backward. | ||
* @param n - Number of bytes to move back. | ||
*/ | ||
back(n?: number): this; | ||
/** | ||
* Move the pointer to the given offset. | ||
@@ -181,2 +186,8 @@ * @param offset | ||
/** | ||
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer | ||
* forward by `n` bytes. | ||
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8} | ||
*/ | ||
decodeText(n?: number, encoding?: string): string; | ||
/** | ||
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer | ||
@@ -183,0 +194,0 @@ * forward by 1 byte. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IOBuffer = void 0; | ||
const utf8_1 = require("./utf8"); | ||
const text_1 = require("./text"); | ||
const defaultByteLength = 1024 * 8; | ||
@@ -96,2 +96,10 @@ class IOBuffer { | ||
/** | ||
* Move the pointer n bytes backward. | ||
* @param n - Number of bytes to move back. | ||
*/ | ||
back(n = 1) { | ||
this.offset -= n; | ||
return this; | ||
} | ||
/** | ||
* Move the pointer to the given offset. | ||
@@ -287,5 +295,13 @@ * @param offset | ||
readUtf8(n = 1) { | ||
return (0, utf8_1.decode)(this.readBytes(n)); | ||
return (0, text_1.decode)(this.readBytes(n)); | ||
} | ||
/** | ||
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer | ||
* forward by `n` bytes. | ||
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8} | ||
*/ | ||
decodeText(n = 1, encoding = 'utf-8') { | ||
return (0, text_1.decode)(this.readBytes(n), encoding); | ||
} | ||
/** | ||
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer | ||
@@ -445,3 +461,3 @@ * forward by 1 byte. | ||
writeUtf8(str) { | ||
return this.writeBytes((0, utf8_1.encode)(str)); | ||
return this.writeBytes((0, text_1.encode)(str)); | ||
} | ||
@@ -448,0 +464,0 @@ /** |
{ | ||
"name": "iobuffer", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Read and write binary data on ArrayBuffers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/IOBuffer.js", |
@@ -30,3 +30,3 @@ # iobuffer | ||
Complete [API documentation](https://image-js.github.io/iobuffer/classes/_iobuffer_.iobuffer.html) | ||
Complete [API documentation](http://image-js.github.io/iobuffer/) | ||
@@ -60,3 +60,3 @@ ## Usage example | ||
[npm-url]: https://www.npmjs.com/package/iobuffer | ||
[ci-image]: https://github.com/image-js/iobuffer/workflows/Node.js%20CI/badge.svg?branch=master | ||
[ci-image]: https://github.com/image-js/iobuffer/workflows/Node.js%20CI/badge.svg?branch=main | ||
[ci-url]: https://github.com/image-js/iobuffer/actions?query=workflow%3A%22Node.js+CI%22 | ||
@@ -63,0 +63,0 @@ [codecov-image]: https://img.shields.io/codecov/c/github/image-js/iobuffer.svg |
@@ -1,2 +0,2 @@ | ||
import { decode, encode } from './utf8'; | ||
import { decode, encode } from './text'; | ||
@@ -145,2 +145,11 @@ const defaultByteLength = 1024 * 8; | ||
/** | ||
* Move the pointer n bytes backward. | ||
* @param n - Number of bytes to move back. | ||
*/ | ||
public back(n = 1): this { | ||
this.offset -= n; | ||
return this; | ||
} | ||
/** | ||
* Move the pointer to the given offset. | ||
@@ -362,2 +371,11 @@ * @param offset | ||
/** | ||
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer | ||
* forward by `n` bytes. | ||
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8} | ||
*/ | ||
public decodeText(n = 1, encoding = 'utf-8'): string { | ||
return decode(this.readBytes(n), encoding); | ||
} | ||
/** | ||
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer | ||
@@ -364,0 +382,0 @@ * forward by 1 byte. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
116638
2357
0