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

pybuiltinfunc

v1.2.0

Published

Python built-in Functions and Modules in Javascript

Downloads

24

Readme

Python Built-in Functions

What's new in 1.2.0

  • Added new Python Str Type with 39 methods.

What's new in 1.1.9

  • Added new module json.

Why I made this

I loves both Python and Javascript. Then I found that Python Built-in Functions is easier than Javascript.At first, I made this for my personal purpose. Then I decided to publish in both yarn and npm. If you have any idea about add new Built-in Function or Any Bugs, Kindly Contact me through my email.

[email protected]

Installing

// For npm
npm i pybuiltinfunc
// or
// For yarn
yarn add pybuiltinfunc

Importing

// ES5
const { /* Some Functions */ } = require('pybuiltinfunc');

// ES6+
import { /* Some Functions */ } from 'pybuiltinfunc';

Available Functions

You can find these uses with example here

  • abs()
  • all()
  • chr()
  • str()
  • int()
  • float()
  • ord()
  • len()
  • bin()
  • print()
  • min()
  • map()
  • sum()
  • range()
  • type()

Examples

import { print } from "pybuiltinfunc";

print("Hello")
import { print, len } from "pybuiltinfunc";

print(len("Some Text"))

Available Built-in Modules

  • math
    • sqrt()
    • acos()
    • acosh()
    • asin()
    • asinh()
    • atan()
    • atan2()
    • atanh()
    • ceil()
    • comb()
    • factorial()
    • cbrt()
    • copysign()
    • cos()
    • cosh()
    • degrees()
    • dist()
    • exp()
    • expm1()
    • floor()
    • fmod()
    • gcd()
    • hypot()
    • sin()
    • sinh()
    • tan()
    • tanh()
    • pow()
    • prod()
    • isfinite()
    • isinf()
    • isprt()
    • radians()
    • isnan()
    • perm()
    • nan
    • e
    • pi
    • log
    • log2
    • log10
    • log1p
    • tau
  • random
    • randint()
    • uniform()
  • os
    • getcwd()
    • chdir()
    • mkdir()
    • rmdir()
    • remove()
    • listdir()
    • rename()
    • name()
    • path [ os.path ]
      • join()
  • json
    • load()
    • dumps()

Examples

import { print, math } from "pybuiltinfunc";

print(math.sqrt(16))
import { print, random } from "pybuiltinfunc";

print(random.randint(0, 4))

Python List

List in Python and Array in Javascript are same. But, Those who learn Python as first language (like me) would find Python List is easy. So I made this. You can import List class by,

import { List } from "pybuiltinfunc";

Using it is little bit difference,

const list = new List([5, 7, 8, 9])
list.append(7)
print(list.return())

In Above code, You can find list.return(). It is used to return value.

Available Method:

  • append()
  • insert()
  • extend()
  • remove()
  • pop()
  • insert()
  • clear()
  • reverse()
  • count()
  • copy()

Python String

Yeah Python String is also available in this Package. Usage is same as List.

Example

import { Str, print } from "pybuiltinfunc";

const string = new Str("Hello World!")
print(string.return())
print(string.casefold())

Available Methods

  • capitalize()
  • casefold()
  • center()
  • count()
  • endswith()
  • expandtabs()
  • find()
  • index()
  • isalnum()
  • isalpha()
  • isdecimal()
  • isidentifier()
  • isprintable()
  • isdigit()
  • islower()
  • isspace()
  • istitle()
  • isupper()
  • join()
  • ljust()
  • lower()
  • lstrip()
  • partition()
  • replace()
  • rfind()
  • rindex()
  • rjust()
  • rpartition()
  • rsplit()
  • rstrip()
  • split()
  • splitlines()
  • startswith()
  • strip()
  • swapcase()
  • title()
  • translate()
  • upper()
  • zfill()

Python Loops

Python loops in Javascript is seems like insane idea. Let me tell What's difference is You can use == instead of ===, use != instead of !==, use and instead of && and or instead of || .

loop is a object which you can import using ,

import { loop } from 'pybuiltinfunc';

Then using it is super simple and available method are if and ifElse. Here some examples below ,

If Loop

loop.if("5<6", ()=>{
    // some code...
})

After v1.1.8, You can no longer use other than string as first parameter. First Parameter is condition and Second Parameter is an Anonymous Function.

If and Else Loop

loop.if("5<6", ()=>{
    // some code runs if true
}, ()=>{
  // some code runs if false
})

First Parameter is condition, Second Parameter is an Anonymous Function for If condition and Third Parameter is also an Anonymous Function for Else condition.

My Email

[email protected]