Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@hackclub/transcript

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hackclub/transcript

Hackily manage your project strings

canary
latest
npmnpm
Version
0.1.0
Version published
Maintainers
6
Created
Source

transcript

manage your project strings, hackily

how it works

you use a transcript.yml, where you declare key-value yaml pairs of strings. you can use js expressions - as strings are evaled - this means you can use ${templates}, JS expressions, or just getting other strings using tthis.recite().

quirks:

  • ??? may be buggy - will be rewritten shortly!

In the wild

Examples

Hello World!
# transcript.yml
greeting: Hello, world!
const { TranscriptProvider } = require('@hackclub/transcript');
const transcript = new TranscriptProvider('./src/transcript.yml');
transcript.recite('greeting');
// => Hello, world!
Randomness

Just cause you're saying the same thing doesn't mean you need to use the same words every time...

bark:
    - bark
    - bork
    - wh${'o'.repeat(3 + Math.ceil(Math.random()*8))}f
const speak = () => transcript.recite('bark') + '!';

// speak boy!
speak(); // => bark!
speak(); // => whooof!
speak(); // => bork!
// good boy!
Recursion

recite() is available within itself as this.t() so you can spice up your lines with more random flavor text.

# hackclub/toriel transcript.yml
greeting: oh hello! i have tea and a fresh ${this.t('type-of-pie')} pie cooling off... please come over and have some!

type-of-pie:
    - cinnamon
    - butterscotch
    - cinnamon and butterscotch
    - snail # apparently a favorite of hers in Undertale
const { transcript } = require('@hackclub/transcript');
transcript.recite('greeting');
// => oh hello! i have tea and a fresh butterscotch pie cooling off... please come over and have some!
transcript.recite('greeting');
// => oh hello! i have tea and a fresh snail pie cooling off... please come over and have some!
Nested Values

Values are nested in yaml, so you can group your lines by type.

errors:
    notFound: the dog sniffs around, but doesn't look like it found what it's looking for
    missingPermission: what typa kibble ya try'n ta feed me? you can't do that!
    general: something went wrong!
try {
	// ... some code
} catch (e) {
	let type = 'general';
	if (e instanceof NotFoundError) type = 'notFound';
	if (e instanceof MissingPermError) type = 'missingPermission';

	transcript.recite(`errors.${type}`);
	// this will give different messages, depending on how your code failed!
}

FAQs

Package last updated on 23 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts