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.0.0.tar.gz (3.7 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.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: js-liner-0.0.0.tar.gz
  • Upload date:
  • Size: 3.7 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.0.0.tar.gz
Algorithm Hash digest
SHA256 30150f086178c220742f9f4da94fd1edc752b0bd199af74e084a73f3bea7e807
MD5 fb8845ddfce75232865c62aee55bf212
BLAKE2b-256 17ad6fddb4cee2e81aa5e86d2ba96ead2130bd8b0ffa9e31326dec63ec8d5e9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: js_liner-0.0.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa4eca812a0356acc13373faaa5b4b5d8cf40e39ca80202029da4d6aa27aa7e
MD5 34ab976d5dbfee9cfa2806098cb59ef1
BLAKE2b-256 b48c6fe3758f329670c7f2b46444499e14ff23e145878db4ccbadcebc73aefef

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