Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

are-docs-informative

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

are-docs-informative - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

lib/index.cjs

13

lib/index.d.ts

@@ -1,4 +0,9 @@

import { InformativeDocsOptions } from "./types.js";
export * from "./types.js";
export declare function areDocsInformative(docs: string | string[], name: string | string[], { aliases, uselessWords, }?: InformativeDocsOptions): boolean;
//# sourceMappingURL=index.d.ts.map
interface InformativeDocsOptions {
aliases?: Record<string, string[]>;
existingName?: string | string[];
uselessWords?: string[];
}
declare function areDocsInformative(docs: string | string[], name: string | string[], { aliases, uselessWords, }?: InformativeDocsOptions): boolean;
export { InformativeDocsOptions, areDocsInformative };

@@ -1,34 +0,31 @@

export * from "./types.js";
const defaultAliases = {
a: ["an", "our"],
// src/index.ts
var defaultAliases = {
a: ["an", "our"]
};
const defaultUselessWords = ["a", "an", "i", "in", "of", "s", "the"];
export function areDocsInformative(docs, name, { aliases = defaultAliases, uselessWords = defaultUselessWords, } = {}) {
const docsWords = new Set(splitTextIntoWords(docs));
const nameWords = splitTextIntoWords(name);
for (const nameWord of nameWords) {
docsWords.delete(nameWord);
}
for (const uselessWord of uselessWords) {
docsWords.delete(uselessWord);
}
return !!docsWords.size;
function normalizeWord(word) {
const wordLower = word.toLowerCase();
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return aliases[wordLower] ?? wordLower;
}
function splitTextIntoWords(text) {
return (typeof text === "string" ? [text] : text)
.flatMap((name) => {
return name
.replace(/\W+/gu, " ")
.replace(/([a-z])([A-Z])/gu, "$1 $2")
.trim()
.split(" ");
})
.flatMap(normalizeWord)
.filter(Boolean);
}
var defaultUselessWords = ["a", "an", "i", "in", "of", "s", "the"];
function areDocsInformative(docs, name, {
aliases = defaultAliases,
uselessWords = defaultUselessWords
} = {}) {
const docsWords = new Set(splitTextIntoWords(docs));
const nameWords = splitTextIntoWords(name);
for (const nameWord of nameWords) {
docsWords.delete(nameWord);
}
for (const uselessWord of uselessWords) {
docsWords.delete(uselessWord);
}
return !!docsWords.size;
function normalizeWord(word) {
const wordLower = word.toLowerCase();
return aliases[wordLower] ?? wordLower;
}
function splitTextIntoWords(text) {
return (typeof text === "string" ? [text] : text).flatMap((name2) => {
return name2.replace(/\W+/gu, " ").replace(/([a-z])([A-Z])/gu, "$1 $2").trim().split(" ");
}).flatMap(normalizeWord).filter(Boolean);
}
}
//# sourceMappingURL=index.js.map
export {
areDocsInformative
};
{
"name": "are-docs-informative",
"version": "0.0.0",
"version": "0.0.1",
"description": "Checks whether a documentation description introduces any new information.",

@@ -12,2 +12,12 @@ "repository": {

"type": "module",
"exports": {
".": {
"types": {
"import": "./lib/index.d.ts",
"require": "./lib/index.d.cts"
},
"import": "./lib/index.js",
"require": "./lib/index.cjs"
}
},
"main": "./lib/index.js",

@@ -22,2 +32,3 @@ "files": [

"build": "tsc",
"build:full": "tsup src/index.ts --clean --format cjs,esm --outDir lib --dts && cp lib/index.d.ts lib/index.d.cts",
"format": "prettier \"**/*\" --ignore-unknown",

@@ -71,2 +82,3 @@ "format:write": "pnpm format --write",

"should-semantic-release": "^0.1.0",
"tsup": "^6.7.0",
"typescript": "^5.0.0",

@@ -73,0 +85,0 @@ "vitest": "^0.29.0",

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