Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tbeseda/print-adjacent
Create a string to display two strings side by side. Helpful for printing diffs in a console.
https://github.com/tbeseda/print-adjacent
Last synced: about 1 month ago
JSON representation
Create a string to display two strings side by side. Helpful for printing diffs in a console.
- Host: GitHub
- URL: https://github.com/tbeseda/print-adjacent
- Owner: tbeseda
- Created: 2023-12-15T01:33:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-15T01:37:51.000Z (about 1 year ago)
- Last Synced: 2024-04-15T02:57:46.892Z (10 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/print-adjacent
- Size: 69.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage
Like in a test...
```js
import assert from 'node:assert/strict'
import test from 'node:test'
import printAdjacent from 'print-adjacent'test('Make sure one object is the same as another', () => {
assert.deepStrictEqual(
object1,
object2,
printAdjacent(
['EXPECTED', JSON.stringify(object2, null, 2)],
['ACTUAL', JSON.stringify(object1, null, 2)],
),
)
})
```## Output
```
✖ Make sure one object is the same as another (0.606542ms)
AssertionError [ERR_ASSERTION]:
EXPECTED │ ACTUAL
────────────────────────────┼────────────────────────────
{ │ {
"type": "pair", │ "type": "pair",
"value": [ │ "value": [
{ │ {
"type": null, │ "type": null,
"value": "foo" │ "value": "foo"
}, │ },
{ │ {
"type": "pair", │ "type": "pair",
"value": [ │ "value": [
{ │ {
"type": null, │ "type": null,
"value": "bar" │ "value": "bar"
}, │ },
{ │ {
"type": null, │ "type": null,
"value": "baz" │ "value": "baz"
} │ }
], │ ],
"bar": "baz" │ "bar": "baz"
} │ }
], │ ],
"foo": "bar:baz" │ "foo": [
} │ {
│ "type": null,
│ "value": "bar"
│ },
│ {
│ "type": null,
│ "value": "baz"
│ }
│ ]
│ }
```