← Back to list

implementing-functions
by jasonkuhrt
Opinionated Standard Lib for TypeScript
⭐ 5🍴 0📅 Dec 29, 2025
SKILL.md
name: implementing-functions description: Implements functions following project conventions. Applies data-first parameter order, currying patterns with *On and *With variants, and consistent universal operation names.
Implementing Functions
Steps
- Data first: Accept data as the first parameter
- Curry when sensible: Typically for 2-parameter functions
- Provide both curried variants for most functions
Reference
Currying Pattern
// Base function - data first
export const split = (value: string, separator: string): string[] => { ... }
// *On variant - data first, returns function waiting for second arg
export const splitOn = Fn.curry(split)
// Usage: Str.splitOn(data)(separator)
// *With variant - flipped, returns function waiting for data
export const splitWith = Fn.flipCurried(Fn.curry(split))
// Usage: Str.splitWith(separator)(data)
When to Use Each Variant
*On - When you have data and want to try different operations:
const data = 'name,age,city'
const splitData = Str.splitOn(data)
splitData(',') // ['name', 'age', 'city']
splitData('') // individual chars
*With - When you have an operation and want to apply to different data:
const splitByComma = Str.splitWith(',')
splitByComma('john,25') // ['john', '25']
splitByComma('laptop,999') // ['laptop', '999']
Universal Operations
Maintain consistent names across data structures:
| Operation | Purpose | Examples |
|---|---|---|
merge | Combine two instances | Arr.merge, Obj.merge, Str.merge |
by | Group/index by key | Group.by(array, 'field') |
is | Type predicate | Arr.is, Obj.is, Undefined.is |
Namespace Name Elision
Do NOT repeat the namespace name in function names:
// Correct
Group.by(array, key)
Undefined.is(value)
Str.merge(a, b)
// Incorrect
Group.groupBy(array, key)
Undefined.isUndefined(value)
Type-Level Transformations
Prefer conditional types over function overloads for type mappings:
// ✅ Good - Type-level transformation
type Abs<T extends number> =
T extends Negative ? Positive :
T extends NonPositive ? NonNegative :
NonNegative
const abs = <T extends number>(value: T): Abs<T> => ...
// ❌ Avoid - Function overloads
function abs(value: Negative): Positive
function abs(value: NonPositive): NonNegative
function abs(value: number): NonNegative
Benefits: Cleaner API, better type inference, easier to maintain.
Notes
- Some functions have only data parameters → only
*Onvariant needed - Functions with >2 parameters: currying less common, use judgment
- Data-first enables natural left-to-right composition
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
3ヶ月以内に更新
+5
○フォーク
10回以上フォークされている
0/5
○Issue管理
オープンIssueが50未満
0/5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon


