jest-docblock
Advanced tools
Comparing version 29.7.0 to 30.0.0-alpha.0
@@ -1,6 +0,20 @@ | ||
'use strict'; | ||
/*! | ||
* /** | ||
* * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* * | ||
* * This source code is licensed under the MIT license found in the | ||
* * LICENSE file in the root directory of this source tree. | ||
* * / | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports). | ||
(() => { | ||
var exports = __webpack_exports__; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
}); | ||
})); | ||
exports.extract = extract; | ||
@@ -12,3 +26,3 @@ exports.parse = parse; | ||
function _os() { | ||
const data = require('os'); | ||
const data = require("os"); | ||
_os = function () { | ||
@@ -20,3 +34,3 @@ return data; | ||
function _detectNewline() { | ||
const data = _interopRequireDefault(require('detect-newline')); | ||
const data = _interopRequireDefault(require("detect-newline")); | ||
_detectNewline = function () { | ||
@@ -27,5 +41,3 @@ return data; | ||
} | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -43,4 +55,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
const ltrimNewlineRe = /^(\r?\n)+/; | ||
const multilineRe = | ||
/(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g; | ||
const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g; | ||
const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g; | ||
@@ -62,6 +73,3 @@ const stringStartRe = /(\r?\n|^) *\* ?/g; | ||
const line = (0, _detectNewline().default)(docblock) ?? _os().EOL; | ||
docblock = docblock | ||
.replace(commentStartRe, '') | ||
.replace(commentEndRe, '') | ||
.replace(stringStartRe, '$1'); | ||
docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); | ||
@@ -76,14 +84,8 @@ // Normalize multi-line directives | ||
const result = Object.create(null); | ||
const comments = docblock | ||
.replace(propertyRe, '') | ||
.replace(ltrimNewlineRe, '') | ||
.trimRight(); | ||
const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight(); | ||
let match; | ||
while ((match = propertyRe.exec(docblock))) { | ||
while (match = propertyRe.exec(docblock)) { | ||
// strip linecomments from pragmas | ||
const nextPragma = match[2].replace(lineCommentRe, ''); | ||
if ( | ||
typeof result[match[1]] === 'string' || | ||
Array.isArray(result[match[1]]) | ||
) { | ||
if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) { | ||
result[match[1]] = STRING_ARRAY.concat(result[match[1]], nextPragma); | ||
@@ -99,3 +101,6 @@ } else { | ||
} | ||
function print({comments = '', pragmas = {}}) { | ||
function print({ | ||
comments = '', | ||
pragmas = {} | ||
}) { | ||
const line = (0, _detectNewline().default)(comments) ?? _os().EOL; | ||
@@ -106,6 +111,3 @@ const head = '/**'; | ||
const keys = Object.keys(pragmas); | ||
const printedObject = keys | ||
.flatMap(key => printKeyValues(key, pragmas[key])) | ||
.map(keyValue => `${start} ${keyValue}${line}`) | ||
.join(''); | ||
const printedObject = keys.flatMap(key => printKeyValues(key, pragmas[key])).map(keyValue => `${start} ${keyValue}${line}`).join(''); | ||
if (!comments) { | ||
@@ -120,20 +122,12 @@ if (keys.length === 0) { | ||
} | ||
const printedComments = | ||
comments | ||
.split(line) | ||
.map(textLine => `${start} ${textLine}`) | ||
.join(line) + line; | ||
return ( | ||
head + | ||
line + | ||
(comments ? printedComments : '') + | ||
(comments && keys.length ? start + line : '') + | ||
printedObject + | ||
tail | ||
); | ||
const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line; | ||
return head + line + (comments ? printedComments : '') + (comments && keys.length > 0 ? start + line : '') + printedObject + tail; | ||
} | ||
function printKeyValues(key, valueOrArray) { | ||
return STRING_ARRAY.concat(valueOrArray).map(value => | ||
`@${key} ${value}`.trim() | ||
); | ||
return STRING_ARRAY.concat(valueOrArray).map(value => `@${key} ${value}`.trim()); | ||
} | ||
})(); | ||
module.exports = __webpack_exports__; | ||
/******/ })() | ||
; |
{ | ||
"name": "jest-docblock", | ||
"version": "29.7.0", | ||
"version": "30.0.0-alpha.0", | ||
"repository": { | ||
@@ -15,2 +15,4 @@ "type": "git", | ||
"types": "./build/index.d.ts", | ||
"require": "./build/index.js", | ||
"import": "./build/index.mjs", | ||
"default": "./build/index.js" | ||
@@ -27,3 +29,3 @@ }, | ||
"engines": { | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
"node": "^16.10.0 || ^18.12.0 || >=20.0.0" | ||
}, | ||
@@ -33,3 +35,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630" | ||
"gitHead": "780ae28333df4d188b2ef78bd19d4ed5bc53562d" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9717
6
147
2