twing/README.md

104 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

2024-12-31 12:21:53 +02:00
# Fork notice
This repo is a fork of https://gitlab.com/nightlycommit/twing, with the goal of reducing the bundle size.
Changes made:
- Replaced Browserify with ESBuild
- Removed vulnerable dependencies
- Replaced some of the dependencies with own implementations
- Removed `iconv-lite`
- Removed asynchronous versions of the functions
2024-12-31 17:41:47 +02:00
- The resulting bundle is an ES module (can be `import`ed)
2024-12-31 12:21:53 +02:00
2024-12-31 17:41:47 +02:00
This results in a bundle size reduction from **841 kB** to **336 kB**. The package still passes Twing's original tests (except for encoding, see below).
2024-12-31 12:21:53 +02:00
Caveats:
- Non-UTF-8 runtimes have limited support
- A modern runtime (one that supports `TextEncoder`, typed arrays etc) is required
- Only UTF-8 is supported as the output charset in `convert_encoding`
- SHA256 is replaced by SHA1 in error messages
---
# ORIGINAL README
# Twing
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage percentage][coveralls-image]][coveralls-url] [![Donate][donate-image]][donate-url]
2018-01-03 20:51:46 +02:00
First-class TypeScript and JavaScript Twig compiler
## Prerequisites
This projects needs at least **node.js 16.0.0** to run.
2024-07-25 10:54:18 +03:00
It is also strongly recommended to have [ts-node](https://www.npmjs.com/package/ts-node) and [One Double Zero](https://www.npmjs.com/package/one-double-zero) installed globally to ease the writing of tests and the tracking of the code coverage.
## Usage
### Installation
```shell
npm install
2018-02-10 02:03:10 +02:00
```
### Build the library
2018-03-18 22:10:18 +02:00
```shell
npm run build
```
2019-07-23 14:55:19 +03:00
### Build and run the test suite
2019-07-23 14:55:19 +03:00
```shell
npm run build:test
npm run test
```
2019-07-23 14:55:19 +03:00
### Build and run the test suite in a browser
2019-07-23 14:55:19 +03:00
```shell
npm run build:test
npm run test:browser
```
2019-07-23 14:55:19 +03:00
### Writing and executing tests
2019-07-23 14:55:19 +03:00
2024-04-16 10:33:14 +03:00
Assuming one want to execute the test located in `src/test/tests/integration/comparison/to-array.ts`, one would run:
2019-07-23 14:55:19 +03:00
```shell
2024-04-16 10:33:14 +03:00
ts-node src/test/tests/integration/comparison/to-array.ts
```
2019-07-23 12:16:56 +03:00
It is even possible - and recommended - to track the coverage while writing tests:
```shell
2024-07-25 10:54:18 +03:00
odz ts-node src/test/tests/integration/comparison/to-array.ts
```
Of course, it is also perfectly possible to pipe the result of the test to your favorite tap formatter:
2019-08-15 16:51:25 +03:00
```shell
2024-04-16 10:33:14 +03:00
src/test/tests/integration/comparison$ ts-node . | tap-nyan
9 -_-_-_-_-_,------,
0 -_-_-_-_-_| /\_/\
0 -_-_-_-_-^|__( ^ .^)
-_-_-_-_- "" ""
Pass!
```
2019-08-15 16:51:25 +03:00
2018-03-06 01:17:14 +02:00
## Contributing
2018-02-07 20:58:05 +02:00
2018-03-06 01:17:14 +02:00
* Fork this repository
* Code
2018-09-29 13:06:24 +03:00
* Implement tests using [tape](https://github.com/substack/tape)
2018-03-06 01:17:14 +02:00
* Issue a pull request keeping in mind that all pull requests must reference an issue in the issue queue
2018-02-07 20:58:05 +02:00
2018-03-06 01:17:14 +02:00
## License
2018-02-07 20:58:05 +02:00
Copyright © 2018-2023 [Eric MORAND](https://github.com/ericmorand). Released under the [2-Clause BSD License](https://github.com/ericmorand/twing/blob/master/LICENSE).
2018-02-07 20:58:05 +02:00
[npm-image]: https://badge.fury.io/js/twing.svg
[npm-url]: https://npmjs.org/package/twing
[build-image]: https://gitlab.com/nightlycommit/twing/badges/main/pipeline.svg
[build-url]: https://gitlab.com/nightlycommit/twing/-/pipelines
[coveralls-image]: https://coveralls.io/repos/gitlab/nightlycommit/twing/badge.svg
[coveralls-url]: https://coveralls.io/gitlab/nightlycommit/twing
2018-04-28 14:36:52 +03:00
[donate-image]: https://img.shields.io/badge/Donate-PayPal-green.svg
2023-12-03 17:12:51 +02:00
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7YZU3L2JL2KJA