Socket
Socket
Sign inDemoInstall

markdown-table

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-table - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

20

index.d.ts
/**
* @typedef MarkdownTableOptions
* @property {string|string[]} [align]
* @property {string|null|Array.<string|null|undefined>} [align]
* @property {boolean} [padding=true]

@@ -14,3 +14,3 @@ * @property {boolean} [delimiterStart=true]

*
* @param {string[][]} table
* @param {Array.<Array.<string|null|undefined>>} table
* @param {MarkdownTableOptions} [options]

@@ -20,12 +20,12 @@ * @returns {string}

export function markdownTable(
table: string[][],
options?: MarkdownTableOptions
table: Array<Array<string | null | undefined>>,
options?: MarkdownTableOptions | undefined
): string
export type MarkdownTableOptions = {
align?: string | string[]
padding?: boolean
delimiterStart?: boolean
delimiterEnd?: boolean
alignDelimiters?: boolean
stringLength?: (value: string) => number
align?: string | (string | null | undefined)[] | null | undefined
padding?: boolean | undefined
delimiterStart?: boolean | undefined
delimiterEnd?: boolean | undefined
alignDelimiters?: boolean | undefined
stringLength?: ((value: string) => number) | undefined
}

@@ -1,6 +0,4 @@

import repeat from 'repeat-string'
/**
* @typedef MarkdownTableOptions
* @property {string|string[]} [align]
* @property {string|null|Array.<string|null|undefined>} [align]
* @property {boolean} [padding=true]

@@ -17,3 +15,3 @@ * @property {boolean} [delimiterStart=true]

*
* @param {string[][]} table
* @param {Array.<Array.<string|null|undefined>>} table
* @param {MarkdownTableOptions} [options]

@@ -23,35 +21,33 @@ * @returns {string}

export function markdownTable(table, options) {
var settings = options || {}
var align = (settings.align || []).concat()
var stringLength = settings.stringLength || defaultStringLength
const settings = options || {}
const align = (settings.align || []).concat()
const stringLength = settings.stringLength || defaultStringLength
/** @type {number[]} Character codes as symbols for alignment per column. */
var alignments = []
var rowIndex = -1
const alignments = []
let rowIndex = -1
/** @type {string[][]} Cells per row. */
var cellMatrix = []
const cellMatrix = []
/** @type {number[][]} Sizes of each cell per row. */
var sizeMatrix = []
const sizeMatrix = []
/** @type {number[]} */
var longestCellByColumn = []
var mostCellsPerRow = 0
const longestCellByColumn = []
let mostCellsPerRow = 0
/** @type {number} */
var columnIndex
let columnIndex
/** @type {string[]} Cells of current row */
var row
let row
/** @type {number[]} Sizes of current row */
var sizes
let sizes
/** @type {number} Sizes of current cell */
var size
let size
/** @type {string} Current cell */
var cell
/** @type {string[]} */
var lines
let cell
/** @type {string[]} Chunks of current line. */
var line
let line
/** @type {string} */
var before
let before
/** @type {string} */
var after
let after
/** @type {number} */
var code
let code

@@ -134,3 +130,3 @@ // This is a superfluous loop if we don’t align delimiters, but otherwise we’d

cell = before + repeat('-', size) + after
cell = before + '-'.repeat(size) + after

@@ -155,3 +151,4 @@ if (settings.alignDelimiters !== false) {

rowIndex = -1
lines = []
/** @type {string[]} */
const lines = []

@@ -174,13 +171,13 @@ while (++rowIndex < cellMatrix.length) {

if (code === 114 /* `r` */) {
before = repeat(' ', size)
before = ' '.repeat(size)
} else if (code === 99 /* `c` */) {
if (size % 2) {
before = repeat(' ', size / 2 + 0.5)
after = repeat(' ', size / 2 - 0.5)
before = ' '.repeat(size / 2 + 0.5)
after = ' '.repeat(size / 2 - 0.5)
} else {
before = repeat(' ', size / 2)
before = ' '.repeat(size / 2)
after = before
}
} else {
after = repeat(' ', size)
after = ' '.repeat(size)
}

@@ -252,7 +249,7 @@ }

/**
* @param {string} value
* @param {string|null|undefined} value
* @returns {number}
*/
function toAlignment(value) {
var code = typeof value === 'string' ? value.charCodeAt(0) : 0
const code = typeof value === 'string' ? value.charCodeAt(0) : 0

@@ -259,0 +256,0 @@ return code === 67 /* `C` */ || code === 99 /* `c` */

{
"name": "markdown-table",
"version": "3.0.0",
"version": "3.0.1",
"description": "Markdown tables",

@@ -32,6 +32,2 @@ "license": "MIT",

],
"dependencies": {
"@types/repeat-string": "^1.0.0",
"repeat-string": "^1.0.0"
},
"devDependencies": {

@@ -41,3 +37,2 @@ "@types/tape": "^4.0.0",

"chalk": "^4.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",

@@ -47,7 +42,7 @@ "remark-cli": "^9.0.0",

"rimraf": "^3.0.0",
"strip-ansi": "^6.0.0",
"strip-ansi": "^7.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.39.0"
},

@@ -62,7 +57,2 @@ "scripts": {

},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"prettier": {

@@ -80,6 +70,10 @@ "tabWidth": 2,

"complexity": "off",
"no-var": "off",
"prefer-arrow-callback": "off"
"unicorn/prefer-switch": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"typeCoverage": {

@@ -86,0 +80,0 @@ "atLeast": 100,

@@ -12,4 +12,4 @@ # markdown-table

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.

@@ -16,0 +16,0 @@ [npm][]:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc