javascripthon

1.0.3 • Public • Published

@devendrakanojiya

> Would you console.log()? Nah, I'd print().

Python Syntax supports for some common javascript methods.

<( ̄︶ ̄)>


Installation

  • via npm:
npm install javascripthon

Usage

1. Print (console.log)

print("Namaste Duniya"); // Output: Namaste Duniya
2. Length (len)

print(len([1, 2, 3])); // Output: 3
3. Append (list.append)

const myArray = [1, 2, 3];
append(myArray, 4);
print(myArray); // Output: [1, 2, 3, 4]
4. Slice (similar to slicing)

const slicedArray = slice([1, 2, 3, 4, 5], 1, 4);
print(slicedArray); // Output: [2, 3, 4]
5. Dump/Load (for JSON)

const jsonString = dump({ name: "Goku", aka: "Kakarot" });
print(jsonString); // Output: {"name":"Alice","aka":"Kakarot"}
print(load(jsonString)); // Output: { name: 'Alice', aka: "Kakarot" }
6. Type (similar to type)

print(type(42)); // Output: number
print(type("Hello")); // Output: string
7. Get (similar to dictionary access)

const myObject = { a: 1, b: 2 };
print(get(myObject, 'b')); // Output: 2
8. Random (similar to random.random())

print(random()); // Output: A random number between 0 and 1
9. Sleep (for delays)

(async () => {
    print("Waiting...");
    await sleep(2000);
    print("Done waiting!"); // Output after 2 seconds
})();
10. For Each (similar to for loop)

for_each([1, 2, 3], (item) => print(item)); // Output: 1 2 3

Readme

Keywords

Package Sidebar

Install

npm i javascripthon

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

3.96 kB

Total Files

3

Last publish

Collaborators

  • devenkanojiya