Skip to content

Commit 802e13d

Browse files
author
christinamartinez
committed
Added holdUp and letItCook for async and await, and fixed some of the return mappings.
1 parent 922e561 commit 802e13d

File tree

5 files changed

+63
-11
lines changed

5 files changed

+63
-11
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,24 @@ Your Code | JS
6666
noCap | true
6767
cap | false
6868
onGod | true
69-
ghosted | return null
7069
lowkey.stan("message") | console.log("message")
7170
lowkey.sus("message") | console.warn("message")
7271
lowkey.cringe("message") | console.error("message")
7372
lowkey.tea("message") | console.info("message")
7473
throw new L("message") | throw new Error("message")
7574
yeet(new L("message")) | throw new Error("message")
75+
ghosted | return null
76+
drop(thingToReturn) | return thingToReturn;
77+
itsGiving(thingToReturn) | return thingToReturn;
7678
PERIODT | break
79+
period | break
80+
holdUp(veryCoolFunction) | async function veryCoolFunction()
81+
letItCook(thingToAwait) | await thingToAwait
7782
grab("stash") | require("stash")
7883
module.ship = vibe | module.exports = vibe
7984
fr(assertion) | assert(assertion)
80-
itsGiving(thingToReturn) | return thingToReturn;
8185
outOfPocket | Infinity
82-
"YO".based() | "YO".toLowerCase()
83-
drop(thingToReturn) | return thingToReturn;
86+
"BLAT".based() | "BLAT".toLowerCase()
8487
dis | this
8588

8689
## Contributing

identifierMappings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
stan: "log",
88
sus: "warn",
99
cringe: "error",
10+
tea: "info",
1011
L: "Error",
1112
fr: "assert",
1213
grab: "require",
@@ -16,5 +17,6 @@ module.exports = {
1617
dis: "this",
1718
outOfPocket: "Infinity",
1819
PERIODT: "break",
20+
period: "break",
1921
based: "toLowerCase",
2022
};

index.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = function () {
2-
const identifierMappings = require("./identifierMappings.js")
2+
const identifierMappings = require("./identifierMappings.js");
33

44
const handleIdentifier = (path) => {
55
const newName = identifierMappings[path.node.name];
@@ -22,6 +22,46 @@ module.exports = function () {
2222
};
2323
path.replaceWith(throwStatement);
2424
}
25+
26+
if (
27+
node.expression.type === "CallExpression" &&
28+
(node.expression.callee.name === "itsGiving" ||
29+
node.expression.callee.name === "drop")
30+
) {
31+
const errorArgument = node.expression.arguments[0];
32+
const throwStatement = {
33+
type: "ReturnStatement",
34+
argument: errorArgument,
35+
};
36+
path.replaceWith(throwStatement);
37+
}
38+
39+
if (
40+
node.expression.type === "CallExpression" &&
41+
node.expression.callee.name === "holdUp"
42+
) {
43+
const args = node.expression.arguments;
44+
const asyncFunction = {
45+
type: "FunctionDeclaration",
46+
id: args[0].id,
47+
async: true,
48+
params: [],
49+
body: args[0].body,
50+
};
51+
path.replaceWith(asyncFunction);
52+
}
53+
54+
if (
55+
node.expression.type === "CallExpression" &&
56+
node.expression.callee.name === "letItCook"
57+
) {
58+
const argument = node.expression.arguments[0];
59+
const newNode = {
60+
type: "AwaitExpression",
61+
argument: argument,
62+
};
63+
path.replaceWith(newNode);
64+
}
2565
};
2666

2767
return {

lib/compiled.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
"use strict";
22

3+
require("core-js/modules/es.promise.js");
4+
async function sis() {
5+
await vibeCheck;
6+
}
37
function vibeCheck() {
48
const theVibe = false;
59
const rizz = true;
610
const depression = true;
711
const myGuy = {
812
heat: "Yuh I'm droppin dis heat ❗❗",
913
letHimCook: function letHimCook() {
10-
return (this.heat);
14+
return this.heat;
1115
}
1216
};
1317
console.log(myGuy.letHimCook());
1418
console.warn("the vibes might be off 💀");
15-
assert(rizz === true);
19+
assert(typeof sis === "function");
1620
if (!theVibe) {
1721
if (!rizz) {
1822
throw new Error("mid af");

src/example.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
holdUp(function sis() {
2+
letItCook(vibeCheck);
3+
});
4+
15
function vibeCheck() {
26
const theVibe = cap;
37
const rizz = onGod;
@@ -8,14 +12,14 @@ function vibeCheck() {
812

913
letHimCook: function () {
1014
drop(dis.heat);
11-
}
12-
}
15+
},
16+
};
1317

1418
lowkey.stan(myGuy.letHimCook());
1519

1620
lowkey.sus("the vibes might be off 💀");
1721

18-
fr(rizz === true);
22+
fr(typeof sis === "function");
1923

2024
if (!theVibe) {
2125
if (!rizz) {
@@ -35,4 +39,3 @@ function vibeCheck() {
3539
}
3640

3741
module.ship = vibeCheck;
38-

0 commit comments

Comments
 (0)