Skip to content

Instantly share code, notes, and snippets.

View 3AHAT0P's full-sized avatar
:octocat:

3@H@T0P 3AHAT0P

:octocat:
View GitHub Profile
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@3AHAT0P
3AHAT0P / ChunkerTransformStream.js
Created August 19, 2020 13:25
I created a NodeJS Transform Stream which repack data chunks to necessary size chunks
const { Transform } = require('stream');
const sliceBySize = (buffer, size, callback) => {
let chunk = buffer.slice(0, size);
let index = size;
while (chunk.length >= size) {
callback(chunk);
chunk = buffer.slice(index, index + size);
index += size;