English description follows Japanese.
概要
js_liner は、JavaScript のコードを「正常動作を保ったまま」ワンライナー(1行)に変換する Python ライブラリです。 他の同種ツールに比べ、信頼性とシンプルさを両立しており、煩雑な設定や冗長な機能を省き、純粋に「コードを1行にする」ことに特化しています。
用途
- なんとなくコードをギュッと1行にして気分を変えたいとき
- javascriptが1行じゃないと動かない環境
特徴
- ✅ JavaScript コードを動作・機能を損なわず 1 行に変換
- ✅ 複雑な関数定義や入れ子構造も対応
- ✅ シンプルなインターフェースで即使用可能
- ✅ 他ツールと比べて安定動作
- 🚫 過剰な圧縮や難読化は行わない
- ☕ なんとなく気軽に使える
使用例
import js_liner
script = """
function add(
a, // comment
b
){
return a + b;
}
console.log(add(7, 1));
"""
result = js_liner(script)
print(result) # -> function add(a,b){return a + b;}console.log(add(7, 1));
注意点
-
現バージョンでは、コメントが
//の後にスペースが無い場合、正しく動作しません。- ✅
// comment← OK - ❌
//comment← NG
- ✅
-
コメントの扱いは今後のバージョンで改善予定です。
インストール
pip install js-liner
Overview
js_liner is a Python library that converts JavaScript code into a single line format, while preserving its original behavior. Unlike other similar tools that are often buggy or overloaded with features, this tool is minimal, reliable, and easy to use — focusing solely on converting code into a working one-liner.
Use Cases
- When you just want to crunch your code into a single line for a change of pace
- For environments where JavaScript must run as a one-liner
Features
- ✅ Converts JavaScript code into a single line without breaking functionality
- ✅ Supports nested structures and complex functions
- ✅ Easy-to-use interface — usable right away
- ✅ More stable than many alternatives
- 🚫 No minification or obfuscation
- ☕ Designed for casual and practical use
Example Usage
import js_liner
script = """
function add(
a, // comment
b
){
return a + b;
}
console.log(add(7, 1));
"""
result = js_liner(script)
print(result) # -> function add(a,b){return a + b;}console.log(add(7, 1));
Caveats
-
In the current version, comments without a space after
//may cause issues.- ✅
// comment← OK - ❌
//comment← NG
- ✅
-
Comment handling is planned to improve in future versions.
Installation
pip install js-liner
Metadata
Release files for js-liner 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| js-liner-0.1.0.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| js_liner-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / js-liner-0.1.0.tar.gz
| Download URL | js-liner-0.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59761a3975c72fa597fad19398ad976e744501e46b82904e9da4869474ac6d2f
|
|
BLAKE2b-256 checksum How to use checksums |
bc6f5336006383be3b68f6fa8e59ed91aedec5f7bc255a91491c00b1f5429b74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.3
|
Release files / js_liner-0.1.0-py3-none-any.whl
| Download URL | js_liner-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27a22a24772f4fe861c6a6b0fab238f5145a441c709f8acecf97802ae27d5c46
|
|
BLAKE2b-256 checksum How to use checksums |
9c445068859b4c546287f3bc96a8c7c80a3d0c6adaca61e6f1f2e7e55790d550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.3
|
Security for js-liner 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.