0.2.1 • Published 7 months ago

scratchstatus v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Scratch Status

Dynamic status systems for Scratch and the web.

Using the pre-made Scratch status system

This system was made for use in ocular.

import { scratchstatus } from 'scratchstatus';

const status = `I have {followers} followers.`;

scratchstatus.run(status, 'NFlex23').then(console.log);

Creating a custom status system

import { createConfig, createSystem } from 'scratchstatus';

const config = createConfig({
  initState: (username) => ({
    username,
    count: 1,
  }),
});

const system = createSystem(config, {
  username: {
    args: [],
    description: 'Returns your username',
    do: (_, { username }) => username,
  },
  join: {
    args: ['a', 'b'],
    description: 'Joins a and b together',
    do: ([a, b]) => `${a}${b}`,
  },
  count: {
    args: [],
    description: 'Count by 1',
    do: (_, state) => {
      return state.count++;
    },
  },
});

const status = `I am {username}. {join "Hello, " "World!"}. Counting 1-3: {count}, {count}, {count}`;

system.run(status, 'MystPi').then(console.log);
0.2.1

7 months ago

0.2.0

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago