Huge News!Announcing our $40M Series B led by Abstract Ventures.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.7 to 2.0.8

1

lib/char.d.ts

@@ -23,2 +23,3 @@ import GlitchedWriter from './index';

appendChild(): void;
get interval(): number;
type(): Promise<boolean>;

@@ -25,0 +26,0 @@ step(): void;

@@ -68,5 +68,11 @@ "use strict";

}
get interval() {
let interval = this.writer.options.genInterval;
if (this.gl === '' || this.gl === ' ')
interval /= 2;
return interval;
}
async type() {
const loop = async () => {
!this.special && (await utils_1.wait(this.writer.options.genInterval));
!this.special && (await utils_1.wait(this.interval));
this.step();

@@ -73,0 +79,0 @@ this.writer.emiter.call('step');

@@ -33,2 +33,4 @@ "use strict";

const { htmlElement, writerData } = this.writer;
if (!htmlElement || typeof CustomEvent === 'undefined')
return;
htmlElement === null || htmlElement === void 0 ? void 0 : htmlElement.dispatchEvent(new CustomEvent('gw-finished', { detail: writerData }));

@@ -35,0 +37,0 @@ }

@@ -20,2 +20,4 @@ import Options from './options';

write(string: string, writeOptions?: WriteOptions): Promise<WriterDataResponse>;
add(string: string): Promise<WriterDataResponse>;
remove(n: number): Promise<WriterDataResponse>;
play(playOptions?: PlayOptions): Promise<WriterDataResponse>;

@@ -22,0 +24,0 @@ pause(): void;

40

lib/index.js

@@ -80,2 +80,11 @@ "use strict";

}
async add(string) {
const { previousString } = this;
return this.write(previousString + string);
}
async remove(n) {
const { previousString } = this, array = Array.from(previousString);
array.splice(-n);
return this.write(array.join(''), { erase: true });
}
// private logCharTable() {

@@ -132,3 +141,4 @@ // console.table(

const pl = previous[pi];
if (typeof gl === 'object' || utils_1.isSpecialChar(gl)) {
let isSpecial = false;
if (typeof gl === 'object') {
pi--;

@@ -138,4 +148,5 @@ this.setChar(gi, '', typeof gl === 'object' ? gl.tag : gl, undefined, true);

}
isSpecial = utils_1.isSpecialChar(gl);
const fi = gl !== '' ? previous.indexOf(gl, pi) : -1;
if (fi !== -1 && fi - pi <= maxDist) {
if (fi !== -1 && fi - pi <= maxDist && !isSpecial) {
const appendedText = previous.substring(pi, fi);

@@ -147,3 +158,3 @@ this.setChar(gi, gl, gl, appendedText);

else
this.setChar(gi, pl || this.options.space, gl || this.options.space);
this.setChar(gi, pl || this.options.space, gl || this.options.space, '', isSpecial);
});

@@ -158,3 +169,3 @@ this.removeExtraChars(goalStringArray.length);

const pl = previous[pi] || this.options.space;
if (typeof gl === 'object' || utils_1.isSpecialChar(gl)) {
if (typeof gl === 'object') {
pi--;

@@ -164,3 +175,3 @@ this.setChar(gi, '', typeof gl === 'object' ? gl.tag : gl, undefined, true);

}
this.setChar(gi, pl, gl);
this.setChar(gi, pl, gl, undefined, utils_1.isSpecialChar(gl));
});

@@ -186,3 +197,3 @@ this.removeExtraChars(goalStringArray.length);

if (special) {
charTable.splice(ci, 0, new char_1.default('', gl, this, '', true));
charTable.splice(ci, 0, new char_1.default(pl, gl, this, '', true));
return;

@@ -217,4 +228,4 @@ }

const diff = Math.max(goal.length - result.length, 0);
if (diff > 0 && this.options.space !== '')
result = result.padEnd(diff, ' ');
if (diff > 0 && this.options.space === ' ')
result = result.padEnd(diff + result.length, ' ');
return result;

@@ -229,14 +240,1 @@ }

exports.glitchWrite = glitchWrite;
// const writer = new GlitchedWriter(undefined, { html: true }, string =>
// console.log(string),
// )
// // eslint-disable-next-line func-names
// ;(async function () {
// await wait(1200)
// await writer.write('<h3>This is only the beginning.</h3>')
// await wait(1200)
// await writer.write('Please, <b>say something</b>...')
// await wait(1500)
// await writer.write('my <i>old</i> friend.')
// // inputEl.removeAttribute('disabled')
// })()

@@ -50,3 +50,3 @@ "use strict";

terminal: {
interval: 50,
interval: 30,
initialDelay: [0, 0],

@@ -58,2 +58,4 @@ steps: 0,

oneAtATime: true,
fillSpace: false,
glyphsFromString: false,
startFrom: 'erase',

@@ -60,0 +62,0 @@ },

{
"name": "glitched-writer",
"version": "2.0.7",
"description": "Glitched, text writing module. Highly customizable settings. Decoding, decrypting, scrambling, and simply spelling text. For web and node",
"version": "2.0.8",
"description": "Glitched, text writing module. Highly customizable settings. Decoding, decrypting, scrambling, and simply spelling text. For web and node.",
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",

@@ -18,3 +18,3 @@ "license": "MIT",

"scripts": {
"start": "nodemon src/index.ts",
"start": "nodemon test/index.ts",
"dev": "parcel dev/index.html",

@@ -28,4 +28,4 @@ "build": "tsc"

"devDependencies": {
"lodash.flattendeep": "^4.4.0",
"@parcel/transformer-sass": "^2.0.0-beta.2",
"@types/jsdom": "^16.2.7",
"@types/lodash.findlastindex": "^4.6.6",

@@ -37,7 +37,9 @@ "@types/lodash.flattendeep": "^4.4.6",

"eslint": "^6.8.0",
"parcel": "^2.0.0-beta.2",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"jsdom": "^16.5.1",
"lodash.debounce": "^4.0.8",
"lodash.flattendeep": "^4.4.0",
"nodemon": "^2.0.7",
"parcel": "^2.0.0-beta.2",
"ts-node": "^9.1.1",

@@ -52,3 +54,3 @@ "typescript": "^4.2.3"

"scramble",
"content",
"animation",
"front-end",

@@ -55,0 +57,0 @@ "web",

@@ -49,3 +49,3 @@ # Glitched Writer

```html
<script src="https://cdn.jsdelivr.net/npm/glitched-writer@2.0.6/lib/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/glitched-writer@2.0.7/lib/index.min.js"></script>
```

@@ -153,2 +153,16 @@

### Add & Remove
.add(string) & .remove(number) are methods usefull for quick, slight changes to the displayed text.
```js
// Let's say current text content is: "Hello World"
Writer.add('!!!')
// -> Hello World!!!
Writer.remove(9)
// -> Hello
```
### Writing HTML

@@ -167,3 +181,3 @@

(**Experimental!**) Splits written text into multiple <span> elements. Then writing letters seperately into these child-elements. As for now: **!Do not work with "html" option!**, only one or the other.
(**Experimental!**) Splits written text into series of <span> elements. Then writing letters seperately into these child-elements. As for now: **!Do not work with "html" option!**, only one or the other.

@@ -177,6 +191,6 @@ ```js

* The shape of one character:
* .gw-char (state classes: .gw-typing or .gw-finished)
* .gw-ghosts
* .gw-letter (also .gw-glitched when it is a "glitched" char.)
* .gw-ghosts
* span.gw-char (state classes: .gw-typing or .gw-finished)
* span.gw-ghosts
* span.gw-letter (also .gw-glitched when it is a "glitched" char.)
* span.gw-ghosts
*/

@@ -206,3 +220,3 @@ ```

- **default** - Loaded automatically, featured on the GIF up top.
- **[default](https://codepen.io/thetarnav/pen/MWWyPzY)** - Loaded automatically, featured on the GIF up top.

@@ -213,7 +227,7 @@ - **nier** - Imitating the way text was appearing in the _NieR: Automata's UI_.

- **terminal** - Imitating being typed by a machine.
- **[terminal](https://codepen.io/thetarnav/pen/mdRyqga)** - Imitating being typed by a machine or a computer.
- **zalgo** - Inspired by the _"zalgo"_ or _"cursed text"_, Ghost characters mostly includes the unicode combining characters, which makes the text glitch vertically.
- **neo** - Recreated: _Justin Windle's ["Text Scramble Effect"](https://codepen.io/soulwire/pen/mErPAK)_
- **[neo](https://codepen.io/thetarnav/pen/vYgYWbb)** - Recreated: _Justin Windle's ["Text Scramble Effect"](https://codepen.io/soulwire/pen/mErPAK)_

@@ -240,7 +254,8 @@ ```js

{
steps?: RangeOrNumber, // [1, 8]
interval?: RangeOrNumber, // [60, 170]
initialDelay?: RangeOrNumber, // [0, 2000]
changeChance?: RangeOrNumber, // 0.6
ghostChance?: RangeOrNumber, // 0.2
// name [min , max ] | const // default
steps?: [number, number] | number, // [1, 8]
interval?: [number, number] | number, // [60, 170]
initialDelay?: [number, number] | number, // [0, 2000]
changeChance?: number, // 0.6
ghostChance?: number, // 0.2
maxGhosts?: number, // '0.2'

@@ -252,6 +267,5 @@ glyphs?: string | string[] | Set<string>, // glyphs.full + glyphs.zalgo

html?: boolean, // false
letterize?: boolean, // false
fillSpace?: boolean // true,
}
type RangeOrNumber = [number, number] | number
```

@@ -271,5 +285,5 @@

- **changeChance** - Percentage Chance for letter to change to something else (from glyph charset) (p: 0-1)
- **changeChance** - Percentage chance for letter to change to glitched one (from glyphs) (p: 0-1)
- **ghostChance** - Percentage Chance for ghost letter to appear (p: 0-1)
- **ghostChance** - Percentage chance for ghost letter to appear (p: 0-1)

@@ -276,0 +290,0 @@ - **maxGhosts** - Maximal number of ghosts to occur

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