Socket
Socket
Sign inDemoInstall

@featherds/utils

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@featherds/utils - npm Package Compare versions

Comparing version 0.12.5 to 0.12.6

4

package.json
{
"name": "@featherds/utils",
"version": "0.12.5",
"version": "0.12.6",
"publishConfig": {

@@ -15,3 +15,3 @@ "access": "public"

],
"gitHead": "902fb935f136f66098ff1f777f7ca1294854cd42"
"gitHead": "efae40a88230bf71e4927f9e40604d095fb92d35"
}

@@ -1,3 +0,4 @@

export declare const _setTimeout: (callback: () => void, timeout: number) => number;
/// <reference types="node" />
export declare const _setTimeout: (callback: () => void, timeout: number) => number | NodeJS.Timeout;
export declare type TimeoutResult = ReturnType<typeof _setTimeout>;
export declare const _clearTimeout: (id: TimeoutResult) => void;

@@ -1,2 +0,13 @@

declare const _default: import("jest-axe").JestAxe;
interface CustomMatchers<R = unknown> {
toHaveNoViolations(): R;
}
declare global {
namespace Vi {
interface Assertion extends CustomMatchers {
}
interface AsymmetricMatchersContaining extends CustomMatchers {
}
}
}
declare const _default: (html: string | Element, additionalOptions?: {}) => Promise<unknown>;
export default _default;

@@ -1,5 +0,5 @@

import { configureAxe } from "jest-axe";
import { default as axeCore } from "axe-core";
import chalk from "chalk";
import { printReceived, matcherHint } from "jest-matcher-utils";
const toHaveNoViolations = {
import { expect } from "vitest";
expect.extend({
toHaveNoViolations(results) {

@@ -28,3 +28,3 @@ if (typeof results.violations === "undefined") {

lineBreak +
printReceived(`${violation.help} (${violation.id})`) +
`${violation.help} (${violation.id})` +
lineBreak +

@@ -46,10 +46,51 @@ chalk.yellow(node.failureSummary || "") +

if (pass) {
return;
return "";
}
return (matcherHint(".toHaveNoViolations") + "\n\n" + `${formatedViolations}`);
return `${formatedViolations}`;
};
return { actual: violations, message, pass };
return { message, pass };
},
};
expect.extend(toHaveNoViolations);
});
function configureAxe(runnerOptions = {}) {
return function axe(html, additionalOptions = {}) {
const { element, restore } = mount(html);
const options = Object.assign({}, runnerOptions, additionalOptions);
return new Promise((resolve) => {
axeCore.run(element, options, (err, results) => {
restore();
if (err)
throw err;
resolve(results);
});
});
};
}
function mount(html) {
if (isHTMLElement(html)) {
const el = html;
if (document.body.contains(el)) {
return { element: html, restore: () => undefined };
}
html = el.outerHTML;
}
if (isHTMLString(html)) {
const str = html;
const originalHTML = document.body.innerHTML;
const restore = () => {
document.body.innerHTML = originalHTML;
};
document.body.innerHTML = str;
return { element: document.body, restore };
}
if (typeof html === "string") {
throw new Error(`html parameter ("${html}") has no elements`);
}
throw new Error(`html parameter should be an HTML string or an HTML element`);
}
function isHTMLElement(html) {
return !!html && typeof html === "object" && typeof html.tagName === "string";
}
function isHTMLString(html) {
return typeof html === "string" && /(<([^>]+)>)/i.test(html);
}
export default configureAxe({

@@ -56,0 +97,0 @@ runOnly: {

@@ -1,7 +0,15 @@

import { configureAxe } from "jest-axe";
import { AxeResults, Result } from "axe-core";
import { AxeResults, Result, default as axeCore } from "axe-core";
import chalk from "chalk";
import { printReceived, matcherHint } from "jest-matcher-utils";
import { expect } from "vitest";
interface CustomMatchers<R = unknown> {
toHaveNoViolations(): R;
}
const toHaveNoViolations = {
declare global {
namespace Vi {
interface Assertion extends CustomMatchers {}
interface AsymmetricMatchersContaining extends CustomMatchers {}
}
}
expect.extend({
toHaveNoViolations(results: AxeResults) {

@@ -38,3 +46,3 @@ if (typeof results.violations === "undefined") {

lineBreak +
printReceived(`${violation.help} (${violation.id})`) +
`${violation.help} (${violation.id})` +
lineBreak +

@@ -62,15 +70,62 @@ chalk.yellow(node.failureSummary || "") +

if (pass) {
return;
return "";
}
return (
matcherHint(".toHaveNoViolations") + "\n\n" + `${formatedViolations}`
);
return `${formatedViolations}`;
};
return { actual: violations, message, pass };
return { message, pass };
},
} as jest.ExpectExtendMap;
});
expect.extend(toHaveNoViolations);
function configureAxe(runnerOptions = {}) {
return function axe(html: string | Element, additionalOptions = {}) {
const { element, restore } = mount(html);
const options = Object.assign({}, runnerOptions, additionalOptions);
return new Promise((resolve) => {
axeCore.run(element, options, (err, results) => {
restore();
if (err) throw err;
resolve(results);
});
});
};
}
function mount(html: string | Element) {
if (isHTMLElement(html)) {
const el = html as Element;
if (document.body.contains(el)) {
return { element: html, restore: () => undefined };
}
html = el.outerHTML;
}
if (isHTMLString(html)) {
const str = html as string;
const originalHTML = document.body.innerHTML;
const restore = () => {
document.body.innerHTML = originalHTML;
};
document.body.innerHTML = str;
return { element: document.body, restore };
}
if (typeof html === "string") {
throw new Error(`html parameter ("${html}") has no elements`);
}
throw new Error(`html parameter should be an HTML string or an HTML element`);
}
function isHTMLElement(html: string | Element) {
return !!html && typeof html === "object" && typeof html.tagName === "string";
}
function isHTMLString(html: string | Element) {
return typeof html === "string" && /(<([^>]+)>)/i.test(html);
}
export default configureAxe({

@@ -77,0 +132,0 @@ runOnly: {

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