Skip to content

Estre Modernism javascript patch and Estre javascript Alienese patch. Let it shorter javascript codes.

License

Notifications You must be signed in to change notification settings

SoliEstre/Modernism.js-Alienese.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Korean

Modernism.js & Alienese.js

κ°œμš”

Modernism.js와 Alienese.jsλŠ” JavaScript μ½”λ“œλ₯Ό 더 κ°„κ²°ν•˜κ³  효율적으둜 μž‘μ„±ν•  수 있게 λ„μ™€μ£ΌλŠ” μœ ν‹Έλ¦¬ν‹° λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
2025λ…„ Estre Soliette(SoliEstre)에 μ˜ν•΄ EstreUI.js의 κ΅¬μ„±μš”μ†Œλ‘œμ„œ μž‘μ„±λ˜μ—ˆμœΌλ©° λ™μΌν•˜κ²Œ MIT λΌμ΄μ„ΌμŠ€λ‘œ μ œκ³΅λ©λ‹ˆλ‹€.

Modernism.js

μ†Œκ°œ

Modernism.jsλŠ” JavaScript μ½”λ“œ μž‘μ„± 방식을 ν˜„λŒ€ν™”ν•˜κ³  인라인 ν”„λ‘œμ„Έμ‹±μ„ μœ„ν•œ λ‹€μ–‘ν•œ λ°”μ΄νŒ¨μŠ€μ™€ λͺ½ν‚€ 패치λ₯Ό μ œκ³΅ν•˜λŠ” λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
이 λΌμ΄λΈŒλŸ¬λ¦¬λŠ” JavaScript μ½”λ“œλ₯Ό 더 κ°„κ²°ν•˜κ³  ν‘œν˜„λ ₯ 있게 μž‘μ„±ν•˜μ—¬ μ½”λ“œκ°€ μž₯황해지지 μ•Šλ„λ‘ λ„μ™€μ€λ‹ˆλ‹€.
사싀 Kotlinμ—μ„œ 잘 μ“°λ˜κ²Œ μ—†μ–΄μ„œ λ§Œλ“€μ—ˆμŠ΅λ‹ˆλ‹€.

μ£Όμš” κΈ°λŠ₯

  1. νƒ€μž… κ΄€λ ¨ μƒμˆ˜: κΈ°λ³Έ νƒ€μž…μ— λŒ€ν•œ λͺ…ν™•ν•œ μƒμˆ˜ μ •μ˜ (undefined, null, function λ“±)
  2. 쑰건뢀 μ‹€ν–‰ μœ ν‹Έλ¦¬ν‹°: executeIf, ifReturn λ“± 쑰건뢀 μ½”λ“œ 싀행을 κ°„μ†Œν™”
  3. 반볡문 μœ ν‹Έλ¦¬ν‹°: forZeroToBefore, forBackward, forin λ“± λ‹€μ–‘ν•œ 루프 νŒ¨ν„΄ 지원
  4. νƒ€μž… 비ꡐ ν•¨μˆ˜: typeOf, typeMatch, isObject λ“± νƒ€μž… 검사 κ°„μ†Œν™”
  5. μΌ€μ΄μŠ€ 맀칭: matchCase, equalCase, typeCase λ“± λ‹€μ–‘ν•œ 쑰건 λΆ„κΈ° νŒ¨ν„΄
  6. 객체 μ‘°μž‘ 도ꡬ: copy, patch, revert λ“± 객체 μ‘°μž‘ μœ ν‹Έλ¦¬ν‹°
  7. ν”„λ‘œν† νƒ€μž… ν™•μž₯: it, let, also λ“± λ©”μ„œλ“œ 체이닝을 μœ„ν•œ ν”„λ‘œν† νƒ€μž… ν™•μž₯

μ‚¬μš© μ˜ˆμ‹œ

// 쑰건뢀 μ‹€ν–‰
let result = executeIf(hour > 10, () => {
    console.log("10μ‹œκ°€ μ§€λ‚¬μœΌλ―€λ‘œ μ•ŒλžŒμ„ μ‹€ν–‰ν•©λ‹ˆλ‹€.");
    return executeAlarm();
}, () => hour);

// λ©”μ„œλ“œ 체이닝
"Hello".let(it => it.toUpperCase()).let(it => it + "!"); // "HELLO!"

// νƒ€μž… μΌ€μ΄μŠ€ 맀칭
const result = value.typeCase({
    [STRING]: v => `λ¬Έμžμ—΄: ${v}`,
    [NUMBER]: v => `숫자: ${v}`,
    [OBJECT]: v => `객체: ${JSON.stringify(v)}`,
    [UNDEFINED]: _ => "μ •μ˜λ˜μ§€ μ•ŠμŒ",
    [NULL]: _ => "null κ°’",
    [DEFAULT]: v => `기타: ${v}`
});

Alienese.js

μ†Œκ°œ

Alienese.jsλŠ” Modernism.js의 ν™•μž₯ 라이브러리둜, Modernism JS μ½”λ“œλ₯Ό 더 짧고 κ°„κ²°ν•˜κ²Œ μž‘μ„±ν•  수 μžˆλ„λ‘ λ‹€μ–‘ν•œ 별칭(alias)을 μ œκ³΅ν•©λ‹ˆλ‹€.
μ½”λ“œλ₯Ό 더 μ•”λ¬΅μ μœΌλ‘œ λ§Œλ“€μ–΄ μ½”λ“œ 크기λ₯Ό 쀄이고 타이핑에 μ†Œμš”λ˜λŠ” μ‹œκ°„μ„ μ€„μ΄λŠ” 것이 λͺ©ν‘œμž…λ‹ˆλ‹€.
μ½”λ“œ νƒ€μ΄ν•‘ν•˜λŠ” μ‹œκ°„λ„ μ•„κΉŒμ›Œμ„œ λ§Œλ“€μ—ˆμŠ΅λ‹ˆλ‹€. κΈ‰ν•  λ•Œ 일단 μ“°κ³  λ‚˜μ€‘μ— Long name으둜 λ°”κΎΈμ„Έμš”.

μ£Όμš” κΈ°λŠ₯

  1. κΈ°λ³Έ νƒ€μž… 별칭: u(undefined), n(null), t(true), f(false) λ“± 짧은 별칭
  2. ν”„λ‘œν† νƒ€μž… 별칭: fnc(Function), str(String), num(Number) λ“±
  3. 클래슀λͺ… 별칭: ra(Array), sa(Set), ma(Map) λ“±
  4. 자주 μ‚¬μš©ν•˜λŠ” 객체 νƒ€μž…: DT(Date), RA(Array), SA(Set) λ“±
  5. λ°”μ΄νŒ¨μŠ€ ν•¨μˆ˜ 별칭: ifx(executeIf), val(valet) λ“±
  6. 루프 ν•¨μˆ˜ 별칭: ff(forForward), fb(forBackward) λ“±
  7. μ •κ·œμ‹ λΉŒλ”: rx, reg, ri λ“± μ •κ·œμ‹ 생성 μœ ν‹Έλ¦¬ν‹°
  8. 특수문자 μƒμˆ˜: lt(<), gt(>), eq(=) λ“± 특수문자 μƒμˆ˜

μ‚¬μš© μ˜ˆμ‹œ

// κΈ°λ³Έ νƒ€μž… 별칭 μ‚¬μš© (νƒ€μž… μƒμˆ˜)
if (x === u) return n;

// νƒ€μž… 검사 μ˜ˆμ‹œ
if (typeOf(value) === STR) {
    console.log("λ¬Έμžμ—΄μž…λ‹ˆλ‹€");
}

// 루프 ν•¨μˆ˜ μ‚¬μš©
ff(array, (i, v) => {
    console.log(i, v);
});

// μ •κ·œμ‹ λΉŒλ” μ‚¬μš©
const regex = ri(value + "pattern"); // new RegEx(value + pattern, "i")와 동일

// 객체 λ©”μ„œλ“œ λ°”λ‘œκ°€κΈ°
const keys = ok(myObject); // Object.keys(myObject)와 동일

// λΉ λ₯Έ μ‹€ν–‰ 큐 λ°œμƒ & λΉ λ₯Έ ν˜„μž¬ λ‚ μ§œ/μ‹œκ°„ νšλ“
pq(time => runZeroDelayed(), dt.n);
// setTimeout(time => runZeroDelayed(), 0, new Date())와 동일

μ„€μΉ˜ 및 μ‚¬μš©λ²•

  1. Modernism.js와 Alienese.js(μ˜΅μ…˜) νŒŒμΌμ„ ν”„λ‘œμ νŠΈμ— 포함
  2. Modernism.jsλ₯Ό λ¨Όμ € λ‘œλ“œν•œ ν›„ Alienese.jsλ₯Ό λ‘œλ“œ
  3. ν•„μš”ν•œ ν•¨μˆ˜μ™€ 별칭을 μ‚¬μš©ν•˜μ—¬ μ½”λ“œ μž‘μ„±

μ£Όμ˜μ‚¬ν•­

  • Alienese.js μ‚¬μš© μ‹œ λ°˜λ“œμ‹œ Modernism.jsλ₯Ό λ¨Όμ € λ‘œλ“œν•΄μ•Ό ν•©λ‹ˆλ‹€.
  • κ°„κ²°ν•œ μ½”λ“œ μž‘μ„±μ„ μœ„ν•œ λΌμ΄λΈŒλŸ¬λ¦¬μ΄λ―€λ‘œ νŒ€ λ‚΄μ—μ„œ μ‚¬μš© μ‹œ μ½”λ“œ κ·œμΉ™μ„ λͺ…ν™•νžˆ μ •μ˜ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.
  • 짧은 별칭듀은 μ½”λ“œ 가독성에 영ν–₯을 쀄 수 μžˆμœΌλ―€λ‘œ μ‚¬μš©μ— μ£Όμ˜κ°€ ν•„μš”ν•©λ‹ˆλ‹€.
    μ€€ λ‚œλ…ν™” μš©λ„μ— 관심이 μ—†κ±°λ‚˜ 짧은 λ³€μˆ˜λͺ…이 μ μœ λ˜λŠ” 것을 μ›μΉ˜ μ•ŠλŠ” 경우λ₯Ό κ³ λ €ν•˜μ—¬ Modernism.js만 μ‚¬μš©ν•  수 μžˆλ„λ‘ λΆ„λ¦¬λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

λΌμ΄μ„ΌμŠ€

MIT License (c) 2025 Estre Soliette (SoliEstre)



English

Modernism.js & Alienese.js

Overview

Modernism.js and Alienese.js are utility libraries that help write JavaScript code more concisely and efficiently.
They were created in 2025 by Estre Soliette (SoliEstre) as components of EstreUI.js and are also provided under the MIT license.

Modernism.js

Introduction

Modernism.js is a library that modernizes JavaScript code writing styles and provides various bypasses and monkey patches for inline processing.
This library helps write JavaScript code more concisely and expressively, preventing code from becoming verbose.
Actually, I created it because I missed features I used in Kotlin.

Key Features

  1. Type-related constants: Clear constant definitions for basic types (undefined, null, function, etc.)
  2. Conditional execution utilities: Simplifies conditional code execution with executeIf, ifReturn, etc.
  3. Loop utilities: Support for various loop patterns such as forZeroToBefore, forBackward, forin, etc.
  4. Type comparison functions: Simplifies type checking with typeOf, typeMatch, isObject, etc.
  5. Case matching: Various conditional branching patterns with matchCase, equalCase, typeCase, etc.
  6. Object manipulation tools: Object manipulation utilities such as copy, patch, revert, etc.
  7. Prototype extensions: Prototype extensions for method chaining such as it, let, also, etc.

Usage Examples

// Conditional execution
let result = executeIf(hour > 10, () => {
    console.log("It's past 10 o'clock, executing alarm.");
    return executeAlarm();
}, () => hour);

// Method chaining
"Hello".let(it => it.toUpperCase()).let(it => it + "!"); // "HELLO!"

// Type case matching
const result = value.typeCase({
    [STRING]: v => `String: ${v}`,
    [NUMBER]: v => `Number: ${v}`,
    [OBJECT]: v => `Object: ${JSON.stringify(v)}`,
    [UNDEFINED]: _ => "Undefined",
    [NULL]: _ => "Null value",
    [DEFAULT]: v => `Other: ${v}`
});

Alienese.js

Introduction

Alienese.js is an extension library for Modernism.js that provides various aliases to write Modernism JS code more shortly and concisely.
Its goal is to make code more implicit, reducing code size and time spent on typing.
I made this because I didn't want to waste time typing code. Use it when you're in a hurry, then change to long names later.

Key Features

  1. Basic type aliases: Short aliases like u(undefined), n(null), t(true), f(false), etc.
  2. Prototype aliases: fnc(Function), str(String), num(Number), etc.
  3. Class name aliases: ra(Array), sa(Set), ma(Map), etc.
  4. Commonly used object types: DT(Date), RA(Array), SA(Set), etc.
  5. Bypass function aliases: ifx(executeIf), val(valet), etc.
  6. Loop function aliases: ff(forForward), fb(forBackward), etc.
  7. Regular expression builder: Regular expression creation utilities like rx, reg, ri, etc.
  8. Special character constants: Special character constants like lt(<), gt(>), eq(=), etc.

Usage Examples

// Basic type alias usage (type constants)
if (x === u) return n;

// Type checking example
if (typeOf(value) === STR) {
    console.log("This is a string");
}

// Loop function usage
ff(array, (i, v) => {
    console.log(i, v);
});

// Regular expression builder usage
const regex = ri(value + "pattern"); // Equivalent to new RegEx(value + pattern, "i")

// Object method shortcuts
const keys = ok(myObject); // Equivalent to Object.keys(myObject)

// Quick execution queue & fast current date/time acquisition
pq(time => runZeroDelayed(), dt.n);
// Equivalent to setTimeout(time => runZeroDelayed(), 0, new Date())

Installation and Usage

  1. Include Modernism.js and Alienese.js (optional) files in your project
  2. Load Modernism.js first, then Alienese.js
  3. Write code using the necessary functions and aliases

Precautions

  • When using Alienese.js, Modernism.js must be loaded first.
  • As this is a library for concise code writing, it's advisable to clearly define code rules when used within a team.
  • Short aliases can affect code readability, so caution is needed when using them.
    The libraries are separated so that you can use only Modernism.js if you're not interested in semi-obfuscation purposes or don't want short variable names to be occupied.

License

MIT License (c) 2025 Estre Soliette (SoliEstre)

About

Estre Modernism javascript patch and Estre javascript Alienese patch. Let it shorter javascript codes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published