npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wedgescript

v1.1.0

Published

a simple interpreted stack based golfing language

Downloads

13

Readme

WedgeScript

What is WedgeScript

WedgeScript is a simple interpreted stack based golfing language. This means that its designed to be used for code golfing, which is a programming game where you solve a problem using as little characters as you possibly can. Because WedgeScript is designed especially for this, it is hard to read yet produces very short code.

How to install

WedgeScript is hosted on NPM and thuss can be installed very easily:

npm i wedgescript -g

once its installed you can use the wsi interpreter to run webscript code (wsi stands for WedgeScriptInterpreter).

How to run code directly

The WedgeScript interpeter is able to read code directly from the command line instead of reading it out of a file, this might be handy for when you want to quickly try out something and dont want to make a file specially for this.

To do this, you can simply use the -e option

wsi -e "'Hello World!' o"

This will then output the string 'Hello World!'.

How to run code from a file

Normally you want to run code from a file however, this is done using the -i command line option (which is default so you can leave it away).

wsi -i somefile.wsc

or

wsi somefile.wsc

How watch a file for updates

(WARNING: this feature is still experimental and breaks if your program contains infinite loops) If you are lazy and dont want to keep running the wsi command to restart the interpreter, you could use the -w option to watch the file for updates, and execute it every time you save it.

wsi -w somefile.wsc

language guide

As mentioned before, WedgeScript is a stack based language, this means that while the interpreter is running, it has a first in first out datastructure under the hood, to which you can push and pop values like an array.

As an example, you can push numbers by simply writing the number down 69 420 will first push 69 and then 420 to the stack, meaning the total length of the stack will be 2 elements. You can also use the - sign to indicate negative numbers and . to indicate fractions. Another literal you can push to the stack is strings, which are notated using ''.

Then there are a whole bunch of commands that are single ascii characters that represent actions that can be done to the stack, for example: the + character can be used to pop 2 values from the stack, add them together and then push the result back onto the stack. Another example is d which is used to duplicate the top value of the stack, Or o which is used to output the top value to the stack.

WedgeScript also has constructs like if, for and while, these are notated with (), {}, and [] respectively.

Lets take a look at for loops, consider the code 5 4{o} this will first push 5, and then push 4, then we encounter a for loop, a for loop will pop the top value from the stack (which in this case is 4) and thats how many times it will loop. therefore the code 1 100 {1 +o} will loop 100 times and increment the 1 every time and print it, therefore printing the numbers 1 to 100.

While statements are roughly the same but will instead pop a value every itteration and continue looping as long as that value is not 0, consider the code: 100 [od1 -] this will push the number 100, then print it, subtract one from it, and repeat that until its 0.

If statements are one again the same idea, instead it will pop only once and not repeat, if the value popped is 0, it will skip the code in (), else it will just execute it. Consider the following code 4 (7 +)o this will push the number 4, if that is not 0, it will push 7 and add that creating 4 + 7 = 11, and then print that.

Wedgescipt also has the ability to push character literals to the stack with

command table

| command | description | |----|---| | p | pops the top value from the stack and discards it | | d | pops the top value from the stack, and pushes it back twice, duplicating it | | c | combines the top 2 values by removing the from the stack and pushing them back as an array containing both of them | | C | first pops a value from the stack representing the count, then pop 'count' more values and combine them together in an array | | o | outputs the top value of the stack, no matter if its a string, an array, a number or whatever | | t | type convert, converts a type to another, for example it converts a number to a string (decoding it by ascii), turns an array of strings to a single string, an array of numbers into a string, etc | | : | concats the top 2 values on the stack, works with arrays and also with strings | | + | pops 2 values from the stack, adds them, pushes the result back | | - | pops 2 values from the stack, subtracts them, pushes the result back | | * | pops 2 values from the stack, multiplies them, pushes the result back | | / | pops 2 values from the stack, divides them, pushes the result back | | | | Loops everything after this infinitely | | ' | character literal push, takes the next character in the code and pushes that to the stack |