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

pyscript-js

v1.2.5

Published

JavaScript for Python Developers

Downloads

29

Readme

CDN:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/pyscript.min.js" charset="utf-8"></script>

Table of contents

Quick start

Several quick start options are available:

  • Download the latest release
  • Clone the repo: git clone https://github.com/Yaseen549/pyscript-js.git
  • Install with npm: npm i pyscript-js
  • Install with yarn: yarn add pyscript-js

Read the Getting started page for information on the Library contents, examples, and more.

Python Functions

integrated python functions in JavaScript

input()
print()   # Will override print() in JavaScript
jsprint() # to use native js print() method
int()
float()
str()
chr()     # Takes single value eg: chr(95)
chr([])   # Multiple Values as Array eg: print(chr([65,66]))
ascii()   # getting ascii values from string values. eg: ascii("a")
hex()
len()
round()
max()
min()
sum([])
sorted()
type()
pow()
abs()
range()   # range(1,10) or range("a","z")

# random class
random.randint()
random.randrange()
random.choice()
random.shuffle()

# dot functions
"".upper()
"".lower()
"".title()
"".capitalize()
[].append()
[].extend()
[].index()     # find index value of an item in list
"".index()     # find index value of a value in String
[].insert()
[].clear()
[].count()
[].remove()
[].copy()

# in-built existing Js functions of Python
"".join()
"".split()
[].sort()
[].pop()
[].reverse()

# Play Around functions
"".charList() # converts string into list of characters
"".wordList() # converts string(Sentence) into list of Strings(words)

# En-glishers
alphabet()    # Returns alphabet from "a" to "z"
vowels()      # Returns vowels or Array/list. Eg: let a = vowels()/ a = vowels("Hello")
consonants()  # Returns consonants or from [list/Array]/"String"

Stub Code

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>PyScript.js</title>
</head>
<body>

  <!-- Your HTML Code Goes Here -->

  ...

  <!-- End -->

  <!-- Adding Scripts -->
  <!-- Use it above all the Script Files to make use of python functions -->
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/pyscript.min.js" charset="utf-8"></script>
  <!-- User Defined Scripts / Other Scripts below -->
  <script src="ExternalJsFile.js" charset="utf-8"></script>
  <!-- or -->
  <script src="script.js" charset="utf-8"></script>
  <script type="text/javascript">
    print("Hello User!") // inspect -> console tab
  </script>
</body>
</html>

script.js

// script.js file
// program to generate fibonacci series up to n terms

// take input from the user
number = int(input('Enter the number of terms: '));
n1 = 0,
n2 = 1,
nextTerm = 0;

print('Fibonacci Series:');

for (let i = 1; i <= number; i++) {
    print(n1);
    nextTerm = n1 + n2;
    n1 = n2;
    n2 = nextTerm;
}

What's included

Within the download you'll find the following directories and files, logically grouping common assets. You'll see something like this:

PyScript-js/
└── dist/
    └── js/
        ├── pyscript-node.js
        ├── pyscript-node.min.js
        ├── pyscript.js
        └── pyscript.min.js

Bugs and feature requests

Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.