open-index/open-npm huggingface dataset:
npm package: @fsnjs/tokenize
Description: An abstract tokenizer.
Author: Alexander Porrello
Latest version: 2.1.0

# @fsnjs/tokenize

`@fsnjs/tokenize` is a zero-dependency library that facilitates tokenization
for applications such as parsers or interpreters where incoming data
needs to be broken down into tokens for further processing.

The library's primary export is the abstract `Tokenizer` class
that is designed to take in a sequence of values
(e.g., characters, objects, etc.) and convert them into structured tokens
that can later be processed by another part of the application.

An additional export added in v2.0.0 is `StringTokenizer` that provides
various functions that are useful when parsing string inputs.

You can view [detailed documentation here](https://alexporrello.github.io/tokenize.js/).

## Usage Notes

To see `Tokenizer` in action, check out [examples here](https://github.com/alexporrello/tokenize.js/tree/main/src/example).

### `Tokenizer Error`

The `Tokenizer Error` class is an extension of `SyntaxError` that
provides a `format` function. This format function provides you with an
error string in the following format:

```bash
/path/to/my_script.ts:2:4 - error: This is a dumb function, isn't it.

1  function my_function() {
2      throw new Error(`This is a dumb function, isn't it.`);
       ^
3  }
```

The `format` function accepts an object that has the parameters:

| Parameter       | Type                   | Default | Description                                               |
| --------------- | ---------------------- | ------- | --------------------------------------------------------- |
| trimLength      | `number`, `undefined`  | `null`  | The number of lines to precede and follow the error line. |
| lineNumbers     | `boolean`, `undefined` | `true`  | Whether line numbers should be prepended to each line.    |
| showOnlyErrorLn | `boolean`, `undefined` | `null`  | Whether only the error line and caret should be shown.    |

#### `registerColorFunctions`

If you would like your error messages to be automatically colorized,
you can register color functions from a library like `Chalk` with this method.

#### `registerSyntaxHighlighter`

If you would like the code in your error messages to be colorized,
you can register a function that colorizes the output code with this method.

## Changelog

### v2.0.0

-   Introduces `StringTokenizer`, an extension of `Tokenizer` that provides
    useful string utilities.
-   The abstract `R` type in `Tokenizer<T, R>` no longer extends `Token` to
    provide more type flexibility in situations where a `position` is not necessary.
-   A `peek` method was added that returns the value from the top of
    `vals` without unshifting it from `vals`.
-   An `options` parameter was added to `prettyPrint` in `TokenizerError` that
    provides you with the ability to...

    -   Return a chunk of the source with the caret pointer
    -   Add line numbers to the left of each line

#### Breaking Changes

-   `orphan_behavior` was removed from the `consume` function. Orphaned
    tokens are unshifted onto `vals`.
-   `next` was renamed to `shift`, and the `lookahead` parameter was removed.
npm package: @fsnjs/truthy
Description: Easily assert that values are NonNullable or Nullable.
Author: Alexander Porrello
Latest version: 1.0.0

# Truthy

Exports two type assertion functions and a union type `Falsy` that
that are useful for safely asserting that a variable is or is not null.
In the case of _not null_, the type assertion function `isTruthy<T>`
preserves the type of the variable that is passed into the function.
This is useful when applied to filtering `null` or `undefined` values.

## Examples

### Array filtering

```ts
['foo', null, undefined, 'bar'].filter(isTruthy).forEach((val) => {
    // `val` will be typed as a non-nullable string
});
```

### RxJS `filter`

```ts
of('foo', null, 'bar')
    .pipe(filter(isTruthy))
    .subscribe((next) => {
        // 'next' will be typed as a a non-nullable string
    });
```
npm package: @fsoc/smdp
Description: A simple markdown parser.
Author: fs-c
Latest version: 0.2.4

# smdp

A <b>s</b>imple <b>m</b>ark<b>d</b>own <b>p</b>arser. No dependencies and ~300 LOC. Not trying to be fully complete or spec compliant; can parse everything in this README but not much else.

```bash
$ npm i @fsoc/smdp
```

```js
// This example can be found in example/readme.js, assuming you run it from the 
// root of the repository it converts this file (README.md) into HTML. 

const { parse } = require('@fsoc/smdp');
const { readFileSync, writeFileSync } = require('fs');

const markdown = readFileSync('README.md');

const html = parse(markdown);

writeFileSync('README.html', html);
```

The `parse` function accepts a string of markdown as its only argument and outputs a string of HTML. This is the only documented export, other exports are for testing and shouldn't be considered stable.

There's a pretty thorough testing setup, run it with `npm run test`.

## About

This was written to parse simple blog posts, so it handles everything you would likely expect to see in one. Obscure edge cases and rarely used (that is, rarely used or seen by me) features like references and tables aren't implemented.

Take a look at the files in `test/` to see what _is_ implemented. Or just try it out, there's a good chance you don't use the stuff that's not supported anyways.

In any case, if you've discovered a bug or are missing a feature, please feel free to open an issue.
npm package: @fsoft/diff-patch
Description: Deep compare two objects and produces a diffData to transform object1 to object2
Author: Fabio Rotondo
Latest version: 0.1.9

# diff-patch

## Introduction

diff-patch is a library that exposes two functions, `diff` and `patch`.

The library does not have any dependencies.

The `diff` function takes two objects (`obj1` and `obj2`) and deep compares them, returning an object that represents the difference between the two (the `diffData`).
`diffData` is an object that can be used to apply the diff to `obj1` to get an object that is the same as `obj2`.

The `patch` function takes an `obj` and a `diffData` object and applies the diff to the object, returning a new object.

The `diff` and `patch` functions are implemented in the following languages:

  * TypeScript
  * Python3

The `diffData` object **can be used interchangeably between the languages**.\
This makes this library very useful for networked applications, where the client and server are written in different languages.

`diffData` can be serialized to JSON and deserialized back to an object. It aims to be as small as possible, and is designed to be used in a networked environment.

More languages will be added in the future, contributions are welcome.

## Usage

### TypeScript

To install the TypeScript version of diff-patch, run:

```bash
npm install @fsoft/diff-patch
```

Then, in your TypeScript code:

```typescript
import { diff, patch } from '@fsoft/diff-patch';

const obj1 = {
  a: 1,
  b: 2,
  c: {
    d: 3,
    e: 4,
  },
};

const obj2 = {
  a: 1,
  b: 2,
  c: {
    d: 3,
    e: 5,   // changed
  },
};

// create the diff data
const diffData = diff(obj1, obj2);

// show the diff data for debugging
console.log( "diffData: ", diffData);

// apply the diff data to obj1 to get an object that is the same as obj2
const obj3 = patch(obj1, diffData);

// show the result for debugging
console.log( "obj3: ", obj3);
```

## Contributors

This library was created by [Fabio Rotondo](https://github.com/fsoft72).

New language implementations are more than welcome.\
Please open an issue or a pull request if you want to contribute.

**Collaborators**:

  * [Nikola Gluhovic](https://github.com/nini-os)


The official repository for this library is [here](https://github.com/fsoft72/diff-patch).

## License

This library is licensed under the MIT License.\
See the [LICENSE](LICENSE) file for details.