Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brainless

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brainless - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

86

lib/index.js

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

Negative pointer values are also valid, but they are stored in a separate
tape. This means that the total tape length is 2*2^32-1 = 8.589.934.590.
tape. This means that the total tape length is 2*2^32-1 = 8,589,934,590.

@@ -28,5 +28,9 @@ The state of the program when the pointer is outside these valid ranges is

var stdin = typeof input !== "string";
var tape = [0];
var tapeNegative = [];
var ptr = 0;
var meta = {
pointer: 0,
tape: {
p: [0],
n: []
},
};
var stack = [];

@@ -60,3 +64,3 @@ var line = 1;

}
tape[ptr] = line.charCodeAt (0);
meta.tape.p[meta.pointer] = line.charCodeAt (0);
this.close ();

@@ -101,13 +105,13 @@ });

//+
if (ptr >= 0){
tape[ptr]++;
if (meta.pointer >= 0){
meta.tape.p[meta.pointer]++;
}else{
tapeNegative[-ptr]++;
meta.tape.n[-meta.pointer]++;
}
}else if (c === 45){
//-
if (ptr >= 0){
tape[ptr]--;
if (meta.pointer >= 0){
meta.tape.p[meta.pointer]--;
}else{
tapeNegative[-ptr]--;
meta.tape.n[-meta.pointer]--;
}

@@ -117,6 +121,10 @@ }else if (c === 62){

//Set to 0 if it's the first access
if (++ptr >= 0){
if (tape[ptr] === undefined) tape[ptr] = 0;
if (++meta.pointer >= 0){
if (meta.tape.p[meta.pointer] === undefined){
meta.tape.p[meta.pointer] = 0;
}
}else{
if (tapeNegative[-ptr] === undefined) tapeNegative[-ptr] = 0;
if (meta.tape.n[-meta.pointer] === undefined){
meta.tape.n[-meta.pointer] = 0;
}
}

@@ -126,4 +134,4 @@ }else if (c === 60){

//Set to 0 if it's the first access
if (--ptr < 0 && tapeNegative[-ptr] === undefined){
tapeNegative[-ptr] = 0;
if (--meta.pointer < 0 && meta.tape.n[-meta.pointer] === undefined){
meta.tape.n[-meta.pointer] = 0;
}

@@ -134,8 +142,8 @@ }else if (c === 91){

var p;
if (ptr >= 0){
t = tape;
p = ptr;
if (meta.pointer >= 0){
t = meta.tape.p;
p = meta.pointer;
}else{
t = tapeNegative;
p = -ptr;
t = meta.tape.n;
p = -meta.pointer;
}

@@ -163,8 +171,8 @@

var p;
if (ptr >= 0){
t = tape;
p = ptr;
if (meta.pointer >= 0){
t = meta.tape.p;
p = meta.pointer;
}else{
t = tapeNegative;
p = -ptr;
t = meta.tape.n;
p = -meta.pointer;
}

@@ -185,8 +193,8 @@

var p;
if (ptr >= 0){
t = tape;
p = ptr;
if (meta.pointer >= 0){
t = meta.tape.p;
p = meta.pointer;
}else{
t = tapeNegative;
p = -ptr;
t = meta.tape.n;
p = -meta.pointer;
}

@@ -203,8 +211,8 @@ process.stdout.write (String.fromCharCode (t[p]));

var p;
if (ptr >= 0){
t = tape;
p = ptr;
if (meta.pointer >= 0){
t = meta.tape.p;
p = meta.pointer;
}else{
t = tapeNegative;
p = -ptr;
t = meta.tape.n;
p = -meta.pointer;
}

@@ -220,7 +228,3 @@ t[p] = input[0].charCodeAt (0);

stdout = true;
process.stdout.write (msg +
JSON.stringify ({
pointer: ptr,
tape: { p: tape, n: tapeNegative }
}) + "\n");
process.stdout.write (msg + JSON.stringify (meta) + "\n");
}else if (c === 10){

@@ -227,0 +231,0 @@ //\n

{
"name": "brainless",
"version": "0.0.2",
"version": "0.0.3",
"description": "Interpreter for the Brainfuck esoteric language",

@@ -11,3 +11,2 @@ "keywords": ["brainfuck", "interpreter"],

},
"license": "MIT",
"dependencies": {

@@ -20,3 +19,4 @@ "argp": "*"

},
"license": "MIT",
"main": "lib"
}

@@ -8,3 +8,3 @@ brainfuck

Version: 0.0.2
Version: 0.0.3

@@ -17,3 +17,3 @@ [Wikipedia page](http://en.wikipedia.org/wiki/Brainfuck).

integer, `2^32-1 = 4,294,967,295 cells`.
Negative pointer values are also valid, but they are stored in a separate tape. This means that the total tape length is `2*(2^32-1) = 8.589.934.590 cells`.
Negative pointer values are also valid, but they are stored in a separate tape. This means that the total tape length is `2*(2^32-1) = 8,589,934,590 cells`.
The state of the program when the pointer is outside these valid ranges is undefined.

@@ -29,15 +29,15 @@ - Each cell stores an IEEE 754 double-precision integer (64 bits), so negative numbers and UTF8 multibyte characters are allowed.

<td>&gt;</td>
<td>Increment the pointer.</td>
<td>Increments the pointer.</td>
</tr>
<tr>
<td>&lt;</td>
<td>Decrement the pointer.</td>
<td>Decrements the pointer.</td>
</tr>
<tr>
<td>+</td>
<td>Increment the cell value where points the pointer.</td>
<td>Increments the cell value where points the pointer.</td>
</tr>
<tr>
<td>-</td>
<td>Decrement the cell value where points the pointer.</td>
<td>Decrements the cell value where points the pointer.</td>
</tr>

@@ -54,7 +54,7 @@ <tr>

<td>[</td>
<td>If the value in the cell where points the pointer is 0 it jumps to the ] token, otherwise it executes the code inside [ and ].</td>
<td>If the value in the cell where points the pointer is 0, it jumps to the ] token, otherwise it executes the code inside [ and ].</td>
</tr>
<tr>
<td>]</td>
<td>If the value in the cell where points the pointer is not 0 it jumps back again to the [ token, otherwise it continues with the program execution.</td>
<td>If the value in the cell where points the pointer is not 0, it jumps back again to the [ token, otherwise it continues with the program execution.</td>
</tr>

@@ -75,3 +75,3 @@ <tr>

If the program needs to read an input value but no string is provided it prompts a cli message asking for a character:
If the program needs to read an input value but no string is provided, it prompts a cli message asking for a character:

@@ -88,3 +88,3 @@ ```

Send a SIGINT (ctrl+c) signal to kill the process.
Send a SIGINT signal (ctrl+c) to kill the process.

@@ -95,3 +95,2 @@ __CLI__

$ brainfuck -h
Usage: brainfuck <input_file> [options]

@@ -119,2 +118,4 @@

___module_(code[, input]) : undefined__
```javascript

@@ -121,0 +122,0 @@ var bf = require ("brainless");

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