Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wooorm/markdown-table
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.0.2
Choose a base ref
...
head repository: wooorm/markdown-table
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.0.3
Choose a head ref
  • 7 commits
  • 6 files changed
  • 2 contributors

Commits on Apr 2, 2022

  1. Replace skypack w/ esm.sh

    wooorm authored Apr 2, 2022
    Copy the full SHA
    646b954 View commit details

Commits on Nov 20, 2022

  1. Update dev-dependencies

    wooorm committed Nov 20, 2022
    Copy the full SHA
    cab9ba8 View commit details
  2. Refactor tsconfig.json

    wooorm committed Nov 20, 2022
    Copy the full SHA
    bcc2b39 View commit details
  3. Use Node test runner

    wooorm committed Nov 20, 2022
    Copy the full SHA
    45d0336 View commit details
  4. Refactor some docs

    wooorm committed Nov 20, 2022
    Copy the full SHA
    d91f3ad View commit details

Commits on Nov 30, 2022

  1. Use ReadonlyArray type in options, parameters

    Closes GH-30.
    
    Reviewed-by: Remco Haszing <remcohaszing@gmail.com>
    Reviewed-by: Titus Wormer <tituswormer@gmail.com>
    bmish authored Nov 30, 2022
    Copy the full SHA
    0107259 View commit details
  2. 3.0.3

    wooorm committed Nov 30, 2022
    Copy the full SHA
    17797f6 View commit details
Showing with 47 additions and 49 deletions.
  1. +4 −4 .github/workflows/main.yml
  2. +2 −2 index.js
  3. +7 −9 package.json
  4. +9 −9 readme.md
  5. +16 −17 test.js
  6. +9 −8 tsconfig.json
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@ jobs:
name: ${{matrix.node}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dcodeIO/setup-node-nvm@master
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{matrix.node}}
- run: npm install
- run: npm test
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
strategy:
matrix:
node:
- lts/erbium
- lts/hydrogen
- node
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @typedef Options
* Configuration (optional).
* @property {string|null|Array<string|null|undefined>} [align]
* @property {string|null|ReadonlyArray<string|null|undefined>} [align]
* One style for all columns, or styles for their respective columns.
* Each style is either `'l'` (left), `'r'` (right), or `'c'` (center).
* Other values are treated as `''`, which doesn’t place the colon in the
@@ -146,7 +146,7 @@
/**
* Generate a markdown ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables)) table..
*
* @param {Array<Array<string|null|undefined>>} table
* @param {ReadonlyArray<ReadonlyArray<string|null|undefined>>} table
* Table data (matrix of strings).
* @param {Options} [options]
* Configuration (optional).
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-table",
"version": "3.0.2",
"version": "3.0.3",
"description": "Generate a markdown (GFM) table",
"license": "MIT",
"keywords": [
@@ -30,25 +30,23 @@
"index.js"
],
"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"chalk": "^5.0.0",
"prettier": "^2.0.0",
"remark-cli": "^10.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"strip-ansi": "^7.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.47.0"
"xo": "^0.53.0"
},
"scripts": {
"prepublishOnly": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"prettier": {
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
@@ -41,23 +41,23 @@ For a complete but heavier solution, build an AST and serialize it with
## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
In Node.js (version 14.14+, 16.0+), install with [npm][]:

```sh
npm install markdown-table
```

In Deno with [Skypack][]:
In Deno with [`esm.sh`][esmsh]:

```js
import {markdownTable} from 'https://cdn.skypack.dev/markdown-table@3?dts'
import {markdownTable} from 'https://esm.sh/markdown-table@3'
```

In browsers with [Skypack][]:
In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import {markdownTable} from 'https://cdn.skypack.dev/markdown-table@3?min'
import {markdownTable} from 'https://esm.sh/markdown-table@3?bundle'
</script>
```

@@ -112,7 +112,7 @@ Yields:

## API

This package exports the following identifiers: `markdownTable`.
This package exports the identifier `markdownTable`.
There is no default export.

### `markdownTable(table[, options])`
@@ -275,12 +275,12 @@ Yields:
## Types

This package is fully typed with [TypeScript][].
It exports additional `Options` type that models its respective interface.
It exports the additional type `Options`.

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
As of now, that is Node.js 14.14+ and 16.0+.
It also works in Deno and modern browsers.

## Security
@@ -321,7 +321,7 @@ See [How to Contribute to Open Source][contribute].

[npm]: https://docs.npmjs.com/cli/install

[skypack]: https://www.skypack.dev
[esmsh]: https://esm.sh

[license]: license

33 changes: 16 additions & 17 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import test from 'tape'
import assert from 'node:assert/strict'
import test from 'node:test'
import chalk from 'chalk'
import strip from 'strip-ansi'
import {markdownTable} from './index.js'

test('markdownTable()', (t) => {
t.equal(
test('markdownTable()', () => {
assert.equal(
markdownTable([
['Branch', 'Commit'],
['main', '0123456789abcdef'],
@@ -19,7 +20,7 @@ test('markdownTable()', (t) => {
'should create a table'
)

t.equal(
assert.equal(
markdownTable([
['Type', 'Value'],
['string', 'alpha'],
@@ -45,7 +46,7 @@ test('markdownTable()', (t) => {
'should serialize values'
)

t.equal(
assert.equal(
markdownTable(
[
['A', 'B', 'C'],
@@ -77,7 +78,7 @@ test('markdownTable()', (t) => {
'should work correctly when cells are missing'
)

t.equal(
assert.equal(
markdownTable(
[
['Beep', 'No.'],
@@ -97,7 +98,7 @@ test('markdownTable()', (t) => {
'should align left and right'
)

t.equal(
assert.equal(
markdownTable(
[
['Beep', 'No.', 'Boop'],
@@ -119,7 +120,7 @@ test('markdownTable()', (t) => {
'should align center'
)

t.equal(
assert.equal(
markdownTable(
[
['Very long', 'Even longer'],
@@ -139,7 +140,7 @@ test('markdownTable()', (t) => {
'should accept a single value'
)

t.equal(
assert.equal(
markdownTable(
[
['Beep', 'No.', 'Boop'],
@@ -161,7 +162,7 @@ test('markdownTable()', (t) => {
'should accept multi-character values'
)

t.equal(
assert.equal(
markdownTable(
[
['Branch', 'Commit'],
@@ -179,7 +180,7 @@ test('markdownTable()', (t) => {
'should create a table without padding'
)

t.equal(
assert.equal(
markdownTable(
[
['Branch', 'Commit', 'Beep', 'No.', 'Boop'],
@@ -197,7 +198,7 @@ test('markdownTable()', (t) => {
'should create a table without aligned delimiters'
)

t.equal(
assert.equal(
markdownTable(
[
['A'],
@@ -217,7 +218,7 @@ test('markdownTable()', (t) => {
'handles short rules and missing elements for tables w/o aligned delimiters'
)

t.equal(
assert.equal(
markdownTable(
[
['Branch', 'Commit'],
@@ -237,7 +238,7 @@ test('markdownTable()', (t) => {
'should create rows without starting delimiter'
)

t.equal(
assert.equal(
markdownTable(
[
['Branch', 'Commit'],
@@ -257,7 +258,7 @@ test('markdownTable()', (t) => {
'should create rows without ending delimiter'
)

t.equal(
assert.equal(
strip(
markdownTable(
[
@@ -284,8 +285,6 @@ test('markdownTable()', (t) => {
].join('\n'),
'should use `stringLength` to detect cell lengths'
)

t.end()
})

/**
17 changes: 9 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"include": ["*.js"],
"include": ["**/**.js"],
"exclude": ["coverage", "node_modules"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020"],
"module": "node16",
"newLine": "lf",
"skipLibCheck": true,
"strict": true
"strict": true,
"target": "es2020"
}
}