docs-and-graphs
Advanced tools
Comparing version 0.1.23 to 0.1.24
{ | ||
"name": "docs-and-graphs", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -6,4 +6,4 @@ import { trim } from './string.js' | ||
function extractBlockIds (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -14,4 +14,4 @@ return [...str.matchAll(BLOCK_ID_REGEXP)].map(x => x[0]).map(trim) | ||
function removeBlockIds (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -18,0 +18,0 @@ return str.replace(BLOCK_ID_REGEXP, '') |
@@ -43,4 +43,4 @@ const PARENTHESIS_TYPES = [ | ||
function extractInlineFields (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -70,4 +70,4 @@ | ||
function removeInlineFields (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -74,0 +74,0 @@ let result = str |
@@ -5,3 +5,5 @@ // [[hello|world]] -> {value:'hello', alias:'world'} | ||
function parseWikilink (str) { | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
const match = str.match(wikilinkRegex) | ||
@@ -24,8 +26,8 @@ if (match) { | ||
function parseExternalLinks (text) { | ||
if (text === undefined) { | ||
return | ||
function parseExternalLinks (str) { | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
// @TODO find a lib to do these sort of things. | ||
const matches = text.match(linkRegex) | ||
const matches = str.match(linkRegex) | ||
if (matches) { | ||
@@ -32,0 +34,0 @@ return { |
@@ -8,4 +8,4 @@ import { removeInlineFields } from './inlineFields.js' | ||
function normalizeText (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -29,3 +29,2 @@ const a = removeInlineFields(str) | ||
} | ||
if (Array.isArray(obj)) { | ||
@@ -44,2 +43,5 @@ return obj.map(element => apply(element, fn)) | ||
function normalizeObject (obj) { | ||
if (obj === undefined || obj === null) { | ||
return obj | ||
} | ||
return apply(obj, str => normalizeText(str)) | ||
@@ -46,0 +48,0 @@ |
@@ -6,4 +6,4 @@ import { trim } from './string.js' | ||
function extractTags (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -14,4 +14,4 @@ return [...str.matchAll(HASH_REGEXP)].map(x => x[0]).map(trim) | ||
function removeTags (str) { | ||
if (str === undefined) { | ||
return | ||
if (str === undefined || str === null) { | ||
return str | ||
} | ||
@@ -18,0 +18,0 @@ return str.replace(HASH_REGEXP, '') |
@@ -33,2 +33,7 @@ import { expect } from 'expect' | ||
}) | ||
it('extractBlockIds of null is null', async function () { | ||
const result = extractBlockIds(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) | ||
@@ -39,3 +44,2 @@ | ||
it(current, async function () { | ||
const txt = removeBlockIds(current) | ||
@@ -50,2 +54,7 @@ expect(txt).toMatchSnapshot(this) | ||
}) | ||
it('removeBlockIds of null is null', async function () { | ||
const result = removeBlockIds(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) |
@@ -47,2 +47,7 @@ import { expect } from 'expect' | ||
}) | ||
it('extractInlineFields of null is null', async function () { | ||
const result = extractInlineFields(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) | ||
@@ -62,2 +67,7 @@ | ||
}) | ||
it('removeInlineFields of null is null', async function () { | ||
const result = removeInlineFields(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) |
@@ -5,5 +5,4 @@ import { expect } from 'expect' | ||
import { | ||
parseWikilink, parseExternalLinks | ||
parseWikilink, parseExternalLinks, | ||
} from '../../src/text/links.js' | ||
import { normalizeText } from '../../src/text/normalize.js' | ||
@@ -27,4 +26,3 @@ const markdown = [ | ||
'<http://example.org>', | ||
'<https://example.org>' | ||
] | ||
'<https://example.org>'] | ||
@@ -54,2 +52,7 @@ expect.extend({ toMatchSnapshot }) | ||
}) | ||
it('parseExternalLinks of null is null', async function () { | ||
const result = parseExternalLinks(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) |
@@ -6,2 +6,3 @@ import { expect } from 'expect' | ||
normalizeText, | ||
normalizeObject | ||
} from '../../src/text/normalize.js' | ||
@@ -28,8 +29,24 @@ | ||
it('normalize of undefined is undefined', async function () { | ||
it('normalizeText of undefined is undefined', async function () { | ||
const result = normalizeText(undefined) | ||
expect(result).toBe(undefined) | ||
}) | ||
it('normalizeText of null is null', async function () { | ||
const result = normalizeText(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) | ||
describe('normalizeObject', async function () { | ||
it('normalizeObject of undefined is undefined', async function () { | ||
const result = normalizeObject(undefined) | ||
expect(result).toBe(undefined) | ||
}) | ||
it('normalizeObject of null is null', async function () { | ||
const result = normalizeObject(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) | ||
@@ -15,3 +15,2 @@ import { expect } from 'expect' | ||
expect.extend({ toMatchSnapshot }) | ||
@@ -26,2 +25,12 @@ | ||
} | ||
it('extractTags of undefined is undefined', async function () { | ||
const result = extractTags(undefined) | ||
expect(result).toBe(undefined) | ||
}) | ||
it('extractTags of null is null', async function () { | ||
const result = extractTags(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) | ||
@@ -42,2 +51,7 @@ | ||
}) | ||
it('removeTags of null is null', async function () { | ||
const result = removeTags(null) | ||
expect(result).toBe(null) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
301366
6016