3.12.1 • Published 1 year ago

tersify v3.12.1

Weekly downloads
297
License
MIT
Repository
github
Last release
1 year ago

tersify

NPM version NPM downloads

GitHub NodeJS Codecov

Semantic Release

Visual Studio Code

Create a readable terse representation of the subject.

You can specify maxLength to further trim the resulting string.

You can also override the result by providing your own tersify() function on the subject.

import { tersify } from 'tersify'

// `() => 'foo'`
tersify(() => { return 'foo' })

// `fn(x, y) { return x + y; }`
tersify(function (x, y) { return x + y })

// `fn foo(y) { return y++; }`
tersify(function foo(y) { return y++ })

// Change result to 80 character long.
// result will have `...` to indicate info missing.
// e.g. `{ a: 'a', ... }`
tersify({...}, { maxLength: 80 })

// '{ a: 1 }`
tersify({ a: 1 })

// `() => Sym(abc)`
tersify(() => { return Symbol.for(abc) })

tersible

Inject a tersify() function to the subject.

import { tersible } from 'tersify'

const increment = tersible(
	a => a + 1,
	() => 'a++'
)
increment.tersify() // 'a++'

// `{ a: 1 }`
tersible({ a: 1 }, function () {
	return `{ a: ${this.a} }`
}).tersify()

const decrement = tersible(a => a--, 'a--')
decrement.tersify() // 'a--'

// `a: 10`
tersible({ a: 1 }, options => `a: ${options.maxLength}`).tersify({ maxLength: 10 })

Tersiblized

Mixin Tersible to a class.

import { Tersiblized } from 'tersify'

class Foo {
	a = 1
}
class Boo extends Tersiblized(Foo, function () {
	return `{ a: ${this.a} }`
}) {}

const boo = new Boo()
boo.a = 3
boo.tersify() // '{ a: 3 }'
3.12.1

1 year ago

3.12.0

1 year ago

3.11.0

1 year ago

3.11.1

1 year ago

3.10.5

2 years ago

3.9.1

2 years ago

3.10.1

2 years ago

3.10.0

2 years ago

3.10.2

2 years ago

3.8.4

2 years ago

3.8.3

2 years ago

3.7.9

2 years ago

3.8.0

2 years ago

3.7.11

2 years ago

3.7.10

2 years ago

3.8.2

2 years ago

3.7.8

3 years ago

3.7.7

3 years ago

3.7.6

3 years ago

3.7.5

3 years ago

3.7.4

4 years ago

3.7.3

4 years ago

3.7.2

4 years ago

3.7.1

4 years ago

3.7.0

4 years ago

3.6.0

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago