Skip to main content

A tool that converts JavaScript code into a single line while keeping it functional.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

js-liner-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

js_liner-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file js-liner-0.1.0.tar.gz.

File metadata

  • Download URL: js-liner-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for js-liner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 59761a3975c72fa597fad19398ad976e744501e46b82904e9da4869474ac6d2f
MD5 e919c72b71e78f26710710144ebc2ae5
BLAKE2b-256 bc6f5336006383be3b68f6fa8e59ed91aedec5f7bc255a91491c00b1f5429b74

See more details on using hashes here.

File details

Details for the file js_liner-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: js_liner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for js_liner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27a22a24772f4fe861c6a6b0fab238f5145a441c709f8acecf97802ae27d5c46
MD5 998d4b677ed3370171487db2845edad0
BLAKE2b-256 9c445068859b4c546287f3bc96a8c7c80a3d0c6adaca61e6f1f2e7e55790d550

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page