Skip to content

Commit

Permalink
Normalization and simplification.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhop committed Oct 23, 2024
1 parent 20a7a5f commit d510622
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
30 changes: 0 additions & 30 deletions tests/ReadString.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Counter.js → tests/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Counter.walk = function walk(o, counter) {
}
};

module.exports = Counter;
module.exports = {Counter};
23 changes: 23 additions & 0 deletions tests/read-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const {Readable} = require('node:stream');

const readString = (string, quant, options) => new Readable(Object.assign({objectMode: true}, options, {
read() {
if (isNaN(quant)) {
this.push(string, 'utf8');
} else if (string instanceof Buffer) {
for (let i = 0; i < string.length; i += quant) {
this.push(string.subarray(i, i + quant));
}
} else {
for (let i = 0; i < string.length; i += quant) {
this.push(string.substr(i, quant), 'utf8');
}
}
this.push(null);
}
}));


module.exports = readString;

0 comments on commit d510622

Please sign in to comment.