@thetimes/methode-parser
Advanced tools
Comparing version 6.2.1 to 7.0.0
@@ -15,18 +15,12 @@ "use strict"; | ||
}); | ||
exports.authorToBylineFactory = (authorSlugs) => (byline) => { | ||
const cleanByline = byline.replace(/\s+/g, " "); | ||
if (!cleanByline.length) { | ||
exports.authorToBylineFactory = (authors) => (byline) => { | ||
if (byline.replace(/\s+/g, "").length === 0) { | ||
return []; | ||
} | ||
const tokenizedByline = cleanByline | ||
.toLowerCase() | ||
.split(/\s/g) | ||
.join("-"); | ||
const bylineAuthorTags = authorSlugs | ||
.map(slug => { | ||
const slugString = String(slug); | ||
const bylineAuthorTags = authors | ||
.map(({ slug, name }) => { | ||
return { | ||
start: tokenizedByline.indexOf(slugString), | ||
length: slugString.length, | ||
slug: slugString | ||
start: byline.toLowerCase().indexOf(name.toLowerCase()), | ||
length: name.length, | ||
slug | ||
}; | ||
@@ -39,7 +33,7 @@ }) | ||
else { | ||
return [createTextElement(cleanByline)]; | ||
return [createTextElement(byline)]; | ||
} | ||
const ast = []; | ||
if (bylineAuthorTags[0].start > 0) { | ||
ast.push(createTextElement(cleanByline.substr(0, bylineAuthorTags[0].start))); | ||
ast.push(createTextElement(byline.substr(0, bylineAuthorTags[0].start))); | ||
} | ||
@@ -54,3 +48,3 @@ bylineAuthorTags.forEach((authorTag, index) => { | ||
attributes: { | ||
value: cleanByline.substr(authorTag.start, authorTag.length) | ||
value: byline.substr(authorTag.start, authorTag.length) | ||
}, | ||
@@ -62,6 +56,6 @@ children: [] | ||
if (bylineAuthorTags[index + 1]) { | ||
ast.push(createTextElement(cleanByline.substring(authorTag.start + authorTag.length, bylineAuthorTags[index + 1].start))); | ||
ast.push(createTextElement(byline.substring(authorTag.start + authorTag.length, bylineAuthorTags[index + 1].start))); | ||
} | ||
else if (cleanByline.length > authorTag.start + authorTag.length) { | ||
ast.push(createTextElement(cleanByline.substr(authorTag.start + authorTag.length))); | ||
else if (byline.length > authorTag.start + authorTag.length) { | ||
ast.push(createTextElement(byline.substr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UFTLENBQ2QsU0FBUyxDQUFDLEtBQUssR0FBRyxTQUFTLENBQUMsTUFBTSxFQUNsQyxnQkFBZ0IsQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUNsQyxDQUNGLENBQ0YsQ0FBQztTQUNIO2FBQU0sSUFBSSxNQUFNLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxLQUFLLEdBQUcsU0FBUyxDQUFDLE1BQU0sRUFBRTtZQUM3RCxHQUFHLENBQUMsSUFBSSxDQUNOLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLEtBQUssR0FBRyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FDckUsQ0FBQztTQUNIO0lBQ0gsQ0FBQyxDQUFDLENBQUM7SUFFSCxPQUFPLEdBQUcsQ0FBQztBQUNiLENBQUMsQ0FBQyJ9 |
import { Slug } from "./markup"; | ||
export declare const authorToBylineFactory: (authorSlugs: Slug[]) => (byline: string) => import("./markup").MarkupElement[]; | ||
declare type AuthorNameAndSlug = { | ||
name: string; | ||
slug: Slug; | ||
}; | ||
export declare const authorToBylineFactory: (authors: AuthorNameAndSlug[]) => (byline: string) => import("./markup").MarkupElement[]; | ||
export {}; |
{ | ||
"name": "@thetimes/methode-parser", | ||
"version": "6.2.1", | ||
"version": "7.0.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "lib/types/index.d.ts", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
57762
1032
1