@techor/one-liner v2.5.17
Getting Started
npm install @techor/one-liner
import oneLiner from '@techor/one-liner';
// or
import { l } from '@techor/one-liner';
l
is equal to l
Strings
l`a ${true && 'b'} c`;
// 'a b c'
Objects
l`a ${{ b: true, c: false, d: isTrue() }} e`;
// 'a b d e'
Arrays
l`a ${['b', 0, false, 'c']} d`;
// 'a b c d'
Resolve types
l`a ${true} ${false} ${''} ${null} ${undefined} ${0} ${NaN} b`
// 'a b'
Trim and clear
- Remove newlines
- Convert consecutive spaces to one space
l`
a
b
${undefined}
c d
`
// 'a b c d'
Mixed and nested
l`
a
${
[
1 && 'b',
{ c: false, d: null },
['e', ['f']]
]
}
g h
`;
// 'a b e f g h'
Execute like a function
l`a b ${['c', 'd']} ${{ e: true, f: false }} ${true && 'g'}`;
// or
line('a b', ['c', 'd'], { e: true, f: false }, true && 'g');
// 'a b c d e g'
Related
- @master/style-element - Quickly create styled React elements with conditional class names
- @master/css - A Virtual CSS language with enhanced syntax
Inspiration
- clsx - A tiny utility for constructing
className
strings conditionally
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago