New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

glitched-writer

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glitched-writer - npm Package Compare versions

Comparing version 2.0.11 to 2.0.12

dist/index.js

3

lib/char.d.ts

@@ -11,3 +11,4 @@ import GlitchedWriter from './index';

instant: boolean;
isWhitespace: boolean;
isSpace: boolean;
afterGlitchChance: number;
els?: {

@@ -14,0 +15,0 @@ charEl: HTMLSpanElement;

@@ -10,3 +10,4 @@ "use strict";

this.instant = false;
this.isWhitespace = false;
this.isSpace = false;
this.afterGlitchChance = 0;
this.writer = writer;

@@ -30,2 +31,3 @@ this.setProps(l, gl, initialGhosts, instant);

setProps(l, gl, initialGhosts = '', instant = false) {
const { options } = this.writer;
this.l = l;

@@ -35,6 +37,8 @@ this.gl = gl;

this.ghostsBefore = [...initialGhosts];
this.stepsLeft = this.writer.options.stepsLeft;
this.stepsLeft = options.stepsLeft;
if (instant)
this.stepsLeft = 0;
this.isWhitespace = utils_1.isSpecialChar(l);
this.isSpace = [' ', ''].includes(l);
this.afterGlitchChance =
(options.ghostChance + options.changeChance) / 3.5;
}

@@ -51,3 +55,3 @@ reset(l, gl, initialGhosts = '', instant = false) {

const { l: char, ghostsAfter, ghostsBefore } = this;
return [ghostsBefore.join(''), char, ghostsAfter.join('')].join('');
return ghostsBefore.join('') + char + ghostsAfter.join('');
}

@@ -61,7 +65,4 @@ get finished() {

return;
const { l } = this, { ghostsBeforeEl, ghostsAfterEl, letterEl } = this.els;
if (this.writer.options.html)
letterEl.innerHTML = l;
else
letterEl.textContent = l;
const { ghostsBeforeEl, ghostsAfterEl, letterEl } = this.els;
letterEl.innerHTML = this.l;
ghostsBeforeEl.textContent = this.ghostsBefore.join('');

@@ -77,3 +78,3 @@ ghostsAfterEl.textContent = this.ghostsAfter.join('');

let interval = this.writer.options.genInterval;
if (this.isWhitespace)
if (this.isSpace)
interval /= 2;

@@ -86,5 +87,8 @@ return interval;

!this.instant && (await utils_1.wait(this.interval));
const lastString = this.string;
this.step();
this.writer.emiter.call('step');
this.writeToElement();
if (lastString !== this.string) {
this.writer.emiter.call('step');
this.writeToElement();
}
this.stepsLeft--;

@@ -104,8 +108,8 @@ };

var _a, _b;
const { ghostChance, changeChance } = this.writer.options;
if ((this.stepsLeft > 0 && this.l !== this.gl) ||
utils_1.coinFlip((ghostChance + changeChance) / 3.5)) {
(utils_1.coinFlip(this.afterGlitchChance) && !this.instant)) {
/**
* IS GROWING
*/
const { ghostChance, changeChance } = this.writer.options;
if (utils_1.coinFlip(ghostChance)) {

@@ -150,2 +154,1 @@ if (this.writer.state.ghostsInLimit)

}
//# sourceMappingURL=char.js.map

@@ -12,2 +12,3 @@ "use strict";

var _a, _b;
this.writer.updateString();
const { htmlElement, writerData } = this.writer, string = eventType === 'finish' ? this.writer.goalString : this.writer.string;

@@ -40,2 +41,1 @@ if (htmlElement && !this.writer.options.letterize) {

exports.default = default_1;
//# sourceMappingURL=emiter.js.map

@@ -15,10 +15,44 @@ import Options from './options';

goalString: string;
string: string;
/**
* Create new instance of Glitched Writer, that manages writing text to one HTML Element. Few writers can possess the same HTML Element, but don't write with them at the same time.
* Use .write(string) method to start writing.
* @param htmlElement HTML Element OR a Selector string (eg. '.text')
* @param options Options object (eg. { html: true, ... }) OR preset name (eg. 'zalgo').
* @param onStepCallback Callback, that will be triggered on every step. Params passed: string & writer data.
* @param onFinishCallback Callback, that will be triggered when each writing finishes. Params passed: string & writer data.
*/
constructor(htmlElement?: HTMLElement | Element | string, options?: ConstructorOptions | PresetName | null, onStepCallback?: Callback, onFinishCallback?: Callback);
get string(): string;
updateString(): void;
get previousString(): string;
/**
* All the data, about current state of the writer instance.
*/
get writerData(): WriterDataResponse;
/**
* Main function of Glitched Writer. It orders writer to start typing passed string. Can be called multiple times after each other, or even during writing.
* @param string text, that will get written.
* @returns Promise, with writer data result
*/
write(string: string, writeOptions?: WriteOptions): Promise<WriterDataResponse>;
/**
* Add text to end method. Orders writer to write same string as previous, but with this added at the end.
* @param string text that will get added
* @returns Promise, with writer data result
*/
add(string: string): Promise<WriterDataResponse>;
/**
* Remove last n-letters method. Orders writer to write same string as previous, but without n-letters at the end.
* @param n number of letters to remove.
* @returns Promise, with writer data result
*/
remove(n: number): Promise<WriterDataResponse>;
/**
* Resume last writing order.
* @returns Promise, with writer data result
*/
play(playOptions?: PlayOptions): Promise<WriterDataResponse>;
/**
* Pause current writer task.
*/
pause(): void;

@@ -25,0 +59,0 @@ private returnResult;

@@ -15,5 +15,14 @@ "use strict";

class GlitchedWriter {
/**
* Create new instance of Glitched Writer, that manages writing text to one HTML Element. Few writers can possess the same HTML Element, but don't write with them at the same time.
* Use .write(string) method to start writing.
* @param htmlElement HTML Element OR a Selector string (eg. '.text')
* @param options Options object (eg. { html: true, ... }) OR preset name (eg. 'zalgo').
* @param onStepCallback Callback, that will be triggered on every step. Params passed: string & writer data.
* @param onFinishCallback Callback, that will be triggered when each writing finishes. Params passed: string & writer data.
*/
constructor(htmlElement, options, onStepCallback, onFinishCallback) {
this.charTable = [];
this.goalString = '';
this.string = '';
if (typeof htmlElement === 'string') {

@@ -28,6 +37,6 @@ if (typeof document !== 'undefined')

this.emiter = new emiter_1.default(this, onStepCallback, onFinishCallback);
this.string = this.previousString;
}
get string() {
const string = this.charTable.map(char => char.string).join('');
return string;
updateString() {
this.string = this.charTable.map(char => char.string).join('');
}

@@ -55,2 +64,5 @@ get previousString() {

// }
/**
* All the data, about current state of the writer instance.
*/
get writerData() {

@@ -65,2 +77,7 @@ const writer = this, { options, state, string } = this;

}
/**
* Main function of Glitched Writer. It orders writer to start typing passed string. Can be called multiple times after each other, or even during writing.
* @param string text, that will get written.
* @returns Promise, with writer data result
*/
async write(string, writeOptions) {

@@ -88,2 +105,7 @@ if (this.options.startFrom === 'erase' && !(writeOptions === null || writeOptions === void 0 ? void 0 : writeOptions.erase))

}
/**
* Add text to end method. Orders writer to write same string as previous, but with this added at the end.
* @param string text that will get added
* @returns Promise, with writer data result
*/
async add(string) {

@@ -93,2 +115,7 @@ const { previousString } = this;

}
/**
* Remove last n-letters method. Orders writer to write same string as previous, but without n-letters at the end.
* @param n number of letters to remove.
* @returns Promise, with writer data result
*/
async remove(n) {

@@ -110,2 +137,6 @@ const { previousString } = this, array = Array.from(previousString);

// }
/**
* Resume last writing order.
* @returns Promise, with writer data result
*/
async play(playOptions) {

@@ -136,2 +167,5 @@ var _a;

}
/**
* Pause current writer task.
*/
pause() {

@@ -160,3 +194,3 @@ this.state.pause();

const appendedText = previous.substring(pi, fi);
this.setChar(gi, gl.value, gl.value, appendedText);
this.setChar(gi, gl.value, gl.value, appendedText, gl.type === 'whitespace');
pi = fi;

@@ -166,3 +200,3 @@ this.state.nGhosts += appendedText.length;

else
this.setChar(gi, pl || this.options.space, gl.value || this.options.space);
this.setChar(gi, pl || this.options.space, gl.value || this.options.space, undefined, gl.type === 'whitespace');
});

@@ -200,11 +234,11 @@ this.removeExtraChars(goalStringArray.length);

// }
setChar(ci, pl, gl, appendedText, special = false) {
setChar(ci, pl, gl, appendedText, instant = false) {
const { charTable } = this, char = charTable[ci];
if (special) {
charTable.splice(ci, 0, new char_1.default(this, pl, gl, '', true));
return;
}
// if (instant) {
// charTable.splice(ci, 0, new Char(this, pl, gl, appendedText, true))
// return
// }
char
? char.reset(pl, gl, appendedText, special)
: charTable.push(new char_1.default(this, pl, gl, appendedText, special));
? char.reset(pl, gl, appendedText, instant)
: charTable.push(new char_1.default(this, pl, gl, appendedText, instant));
}

@@ -247,2 +281,1 @@ get goalStringArray() {

exports.glitchWrite = glitchWrite;
//# sourceMappingURL=index.js.map

@@ -65,2 +65,1 @@ "use strict";

exports.default = Options;
//# sourceMappingURL=options.js.map

@@ -84,2 +84,1 @@ "use strict";

};
//# sourceMappingURL=presets.js.map

@@ -41,2 +41,1 @@ "use strict";

exports.default = State;
//# sourceMappingURL=state.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

@@ -119,2 +119,1 @@ "use strict";

exports.filterHtml = filterHtml;
//# sourceMappingURL=utils.js.map
{
"name": "glitched-writer",
"version": "2.0.11",
"version": "2.0.12",
"description": "Glitched, text writing module. Highly customizable settings. Decoding, decrypting, scrambling, and simply spelling text.",

@@ -12,5 +12,8 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",

"homepage": "https://github.com/thetarnav/glitched-writer#readme",
"main": "lib/index.js",
"main": "dist/index.js",
"types": "lib/index.d.ts",
"jsdelivr": "dist/index.min.js",
"unpkg": "dist/index.min.js",
"files": [
"dist/**/*",
"lib/**/*"

@@ -20,4 +23,4 @@ ],

"start": "nodemon test/index.ts",
"dev": "parcel dev/index.html",
"build": "tsc"
"dev": "parcel dev/index.html --dist-dir dev/dist",
"build": "tsc && grunt build"
},

@@ -32,9 +35,15 @@ "devDependencies": {

"eslint-plugin-import": "^2.22.1",
"grunt": "^1.3.0",
"grunt-cli": "^1.4.1",
"grunt-ts": "^6.0.0-beta.22",
"grunt-webpack": "^4.0.2",
"jsdom": "^16.5.1",
"load-grunt-tasks": "^5.1.0",
"lodash.debounce": "^4.0.8",
"merge2": "^1.4.1",
"nodemon": "^2.0.7",
"parcel": "^2.0.0-beta.2",
"terser-webpack-plugin": "^5.1.1",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
"typescript": "^4.2.3",
"webpack": "^5.28.0"
},

@@ -41,0 +50,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc