Skip to content

Commit 234b883

Browse files
committed
[docs] Updated README
1 parent f7be9af commit 234b883

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

docs/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# JS ❤️ PY
22

3+
## JavaScript and Python Coupling
4+
35
> JS Loves Py is a set of scripts that will allow you to easily pass data back and forth between JavaScript and Python using Json. This demonstrates one way you can couple langauges together to work with one another. The ability to pass data back and forth between two languages like Python and JavaScript opens doors to a universe of new possibilities.
46
57
## [Table Of Contents](#table-of-contents)
@@ -59,15 +61,15 @@ Both the `JS` and the `Py` classes have the exact same functionality and contain
5961

6062
### [JS Class Methods](#js-class-methods)
6163
- `JS.NOTE` - This is where the retieved data from Py is stored
62-
- `JS.PATH` - This will store the path passed to checkForNote()
64+
- `JS.JSON_PATH` - This will store the path passed to checkForNote()
6365
- `JS.sendNoteToPy(note_object, path)`
6466
- `JS.getNoteFromPy(path)`
6567
- `JS.checkForNote(path)`
6668

6769

6870
### [Py Class Methods](#py-class-methods)
6971
- `Py.NOTE` - This is where the retieved data from JS is stored
70-
- `Py.PATH` - This will store the path passed to check_for_note()
72+
- `Py.JSON_PATH` - This will store the path passed to check_for_note()
7173
- `Py.send_note_to_js(self, note_object: dict, path: str)`
7274
- `Py.get_note_from_js(self, path: str)`
7375
- `Py.check_for_note(self, path: str, file: str)`
@@ -117,6 +119,7 @@ py.send_note_to_js({
117119
"title": "Note to JS from Py",
118120
"text": "Hello JavaScript!"
119121
})
122+
```
120123

121124
Once the `send_note_to_js()` method is called the object you passed in will be stored in the ***from_py.json*** file at the specified path and this will automatically be picked up on the JavaScript side by the running `JS.checkForNote()` method from step 1. The data will be stored in the `js.NOTE` property and accessible from there.
122125

js_loves_py.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const fs = require('fs')
22
const path = require('path')
33

44
class JS {
5+
/**
6+
* Creates a Json file with the given object to be picked up
7+
* by the Python Py object.
8+
*/
59
constructor() {
610

711
this.NOTE = null
@@ -54,11 +58,15 @@ class JS {
5458

5559
//Example usage
5660

57-
const js = new JS()
58-
if (js.checkForNote(".")) {
59-
console.log("Data available!!!")
60-
console.log(js.NOTE)
61-
}
61+
// Listen for and get an object from JS.
62+
63+
// const js = new JS()
64+
// if (js.checkForNote(".")) {
65+
// console.log("Data available!!!")
66+
// console.log(js.NOTE)
67+
// }
68+
69+
// Send an object to JS.
6270

6371
// js.sendNoteToPy({
6472
// "name": "javascript",

py_loves_js.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import os
33

44
class Py:
5+
"""
6+
Creates a Json file with the given dictionar to be picked up
7+
by the JavaScript JS object.
8+
"""
59
def __init__(self) -> None:
610
self.NOTE = None
711
self.JSON_PATH = None
@@ -56,11 +60,15 @@ def check_for_note(self, path: str) -> (bool | None):
5660

5761
py = Py()
5862

63+
# Listen for and get an object from JS.
64+
5965
# if py.check_for_note("."):
6066
# print("Data available!")
6167
# print(py.NOTE)
6268

63-
py.send_note_to_js({
64-
"name": "python",
65-
"text": "Hello JavaScript!"
66-
}, "note_from_py.json")
69+
# Send an object to JS.
70+
71+
# py.send_note_to_js({
72+
# "name": "python",
73+
# "text": "Hello JavaScript!"
74+
# }, "note_from_py.json")

0 commit comments

Comments
 (0)