Compare commits

..

No commits in common. "384fda311610ac9490a92f52aa98df82e9b34c91" and "c50bcca6cafcefc6f7b8b93b5df898f801997e07" have entirely different histories.

14 changed files with 249 additions and 494 deletions

View File

@ -1,24 +0,0 @@
name: Node.js CI
on:
push:
branches: ['main']
pull_request:
jobs:
build:
name: 'Node.js build: fmt, clean-install, lint, test'
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
# - 20.x
- latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm run fmt
- run: npm clean-install
- run: npm run lint
- run: npm run test

View File

@ -1,33 +1,20 @@
# [ajquery.js](https://git.coolaj86.com/coolaj86/ajquery.js)
The fastest, most lightweight, fewest dependency jQuery alternative. \
**New**: Now typed, Ai-enhanced, and better than ever!
The fastest, most lightweight, fewest dependency jQuery alternative.
Development Build: 721B (types + comments) \
Production Build: 117B (min + gz)
## Example Usage
Provides modern, advanced CSS4-compatible query selection:
```js
console.log("innerText:", $("p:nth-child(2").innerText);
```
Development Build: 145B (with comments) \
Production Build: 103B (min + gz)
## Install
### via GitHub
```bash
my_ver="v3.0.3"
my_ver="v2.1.2"
mkdir ./vendor/
curl -fsSL "https://raw.githubusercontent.com/coolaj86/ajquery.js/${my_ver}/ajquery.js" \
-o ./vendor/ajquery.js
# Lighthouse-optimized
npx -p uglify-js@3 uglifyjs ./vendor/ajquery.js -o ./vendor/ajquery.min.js
```
```html
@ -37,41 +24,15 @@ npx -p uglify-js@3 uglifyjs ./vendor/ajquery.js -o ./vendor/ajquery.min.js
### via CDN
```html
<script src="https://unpkg.com/ajquery@3.0.3/ajquery.min.js"></script>
<script src="https://unpkg.com/ajquery"></script>
```
Bundler-optimized:
## Example Usage
```html
<script src="https://unpkg.com/ajquery@3.0.3/ajquery.min.cjs"></script>
```
Tree-shaking-optimized:
```html
<script src="https://unpkg.com/ajquery@3.0.3/ajquery.min.mjs"></script>
```
### via NPM
```sh
npm install --save ajquery@3
```
#### CommonJS
Provides modern, advanced CSS4-compatible query selection:
```js
let AJQuery = require("ajquery");
let $ = AJQuery.$;
let $$ = AJQuery.$$;
```
#### ESM
```js
import AJQuery from "ajquery";
let $ = AJQuery.$;
let $$ = AJQuery.$$;
console.log("innerText:", $("p:nth-child(2").innerText);
```
## API
@ -96,7 +57,7 @@ const stylesheets = $$('link[rel="stylesheet"]', head).map(console.log);
## Benchmarks
![ajquery-benchmarks](https://user-images.githubusercontent.com/122831/126774421-1ee009f4-d16d-4710-b041-f19035ff8c35.png "it's over 9000")
![ajquery-benchmarks](https://user-images.githubusercontent.com/122831/126774017-9e2a4f32-3ab8-4ba8-a7f3-290977a49cd0.png "it's over 9000")
## Compatibility

View File

@ -1,49 +0,0 @@
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
* now typed, Ai-enhanced, and better than ever!
* @typedef AJQuery
* @prop {AJQuerySelector} $
* @prop {AJQuerySelectorAll} $$
*/
/**
* Select first matching element, just like console $
* @callback AJQuerySelector
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
/**
* Select all matching child elements as a JS Array, just like console $$
* @callback AJQuerySelectorAll
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
/** @type {AJQuery} */
//@ts-ignore
var AJQuery = ("object" === typeof module && exports) || {};
(function (window, AJQuery) {
"use strict";
/** @type {AJQuerySelector} */
AJQuery.$ = function (cssSelector, $parent = document) {
let $child = $parent.querySelector(cssSelector);
return $child;
};
/** @type {AJQuerySelectorAll} */
AJQuery.$$ = function (cssSelector, $parent = document) {
let nodeList = $parent.querySelectorAll(cssSelector);
let $children = Array.from(nodeList);
return $children;
};
Object.assign(window, AJQuery);
//@ts-ignore
window.AJQuery = AJQuery;
})(globalThis.window || {}, AJQuery);
if ("object" === typeof module) {
module.exports = AJQuery;
}

View File

@ -1,25 +1,7 @@
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
* now typed, Ai-enhanced, and better than ever!
*/
/**
* Select first matching element, just like console $
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $(cssSelector, $parent = document) {
let $child = $parent.querySelector(cssSelector);
return $child;
function $(sel, el) {
return (el || document).querySelector(sel);
}
/**
* Select all matching child elements as a JS Array, just like console $$
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $$(cssSelector, $parent = document) {
let nodeList = $parent.querySelectorAll(cssSelector);
let $children = Array.from(nodeList);
return $children;
function $$(sel, el) {
return Array.from((el || document).querySelectorAll(sel));
}

View File

@ -1,32 +0,0 @@
/** @import('typed-query-selector/strict') */
let AJQuery = { $, $$ };
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
* now typed, Ai-enhanced, and better than ever!
* @namespace AJQuery
*/
/**
* Selects the first element that matches the given selector within the specified parent.
* @param {string} sel - The CSS selector to match.
* @param {Document|Element} [$parent=document] - The parent element to search within. Defaults to document.
*/
function $(sel, $parent = document) {
let $child = $parent.querySelector(sel);
return $child;
}
/**
* Select all matching child elements from $parent (which is document by default)
* @param {String} sel - The CSS selector to match.
* @param {Document|Element} [$parent=document] - The parent element to search within. Defaults to document.
*/
function $$(sel, $parent = document) {
let $children = $parent.querySelectorAll(sel);
let children = Array.from($children);
return children;
}
export default AJQuery;

View File

@ -8,8 +8,6 @@ async function main() {
console.info("Angular: 2517");
await sleep(520);
console.info("React: 3785");
await sleep(128);
console.info("Vite: 6666");
await sleep(230);
console.info('"Vanilla" JS: 6237');
await sleep(65);

View File

@ -6,18 +6,6 @@
<script src="./ajquery.js"></script>
<script>
document.write("Hello, World!");
let text = $("body").textContent;
console.log(text);
</script>
<script src="./ajquery.min.cjs"></script>
<script>
console.log("globalThis.AJQuery:", globalThis.AJQuery);
</script>
<script type="module" src="./ajquery.mjs"></script>
<script type="module">
import AJQuery from "./ajquery.min.mjs";
console.log("imported AJQuery", AJQuery);
console.log($("body").innerText);
</script>
</body>

View File

@ -1,118 +0,0 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["./typings","./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
"noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": [
"ajquery.js",
"ajquery.cjs",
"ajquery.mjs",
"bin/**/*.js",
"lib/**/*.js",
"src/**/*.js"
],
"exclude": ["node_modules"]
}

234
package-lock.json generated
View File

@ -1,13 +1,233 @@
{
"name": "ajquery",
"version": "3.0.3",
"lockfileVersion": 3,
"version": "2.1.2",
"lockfileVersion": 1,
"requires": true,
"packages": {
"": {
"name": "ajquery",
"version": "3.0.3",
"license": "MPL-2.0"
"dependencies": {
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"cli": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz",
"integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=",
"requires": {
"exit": "0.1.2",
"glob": "^7.1.1"
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"console-browserify": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
"integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
"requires": {
"date-now": "^0.1.4"
}
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"date-now": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs="
},
"dom-serializer": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz",
"integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==",
"requires": {
"domelementtype": "^2.0.1",
"entities": "^2.0.0"
},
"dependencies": {
"domelementtype": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz",
"integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A=="
},
"entities": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
}
}
},
"domelementtype": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
"integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w=="
},
"domhandler": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz",
"integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=",
"requires": {
"domelementtype": "1"
}
},
"domutils": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
"integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
"requires": {
"dom-serializer": "0",
"domelementtype": "1"
}
},
"entities": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
"integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY="
},
"exit": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
"integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"htmlparser2": {
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
"integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
"requires": {
"domelementtype": "1",
"domhandler": "2.3",
"domutils": "1.5",
"entities": "1.0",
"readable-stream": "1.1"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"jshint": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.0.tgz",
"integrity": "sha512-Nd+md9wIeyfDK+RGrbOBzwLONSTdihGMtyGYU/t7zYcN2EgUa4iuY3VK2oxtPYrW5ycTj18iC+UbhNTxe4C66g==",
"requires": {
"cli": "~1.0.0",
"console-browserify": "1.1.x",
"exit": "0.1.x",
"htmlparser2": "3.8.x",
"lodash": "~4.17.21",
"minimatch": "~3.0.2",
"shelljs": "0.3.x",
"strip-json-comments": "1.0.x"
}
},
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"prettier": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz",
"integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ=="
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"shelljs": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz",
"integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E="
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"strip-json-comments": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
"integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
}
}
}

View File

@ -1,47 +1,18 @@
{
"name": "ajquery",
"version": "3.0.3",
"description": "The fastest, most lightweight, least dependency jQuery alternative. Now typed, Ai-enhanced, and better than ever!",
"main": "ajquery.cjs",
"module": "ajquery.mjs",
"type": "commonjs",
"browser": {
"ajquery.min.cjs": "ajquery.min.js"
},
"exports": {
".": {
"require": "./ajquery.cjs",
"import": "./ajquery.mjs",
"default": "./ajquery.cjs"
}
},
"version": "2.1.2",
"description": "The fastest, most lightweight, least dependency jQuery alternative",
"main": "ajquery.min.js",
"files": [
"ajquery.js",
"ajquery.min.js",
"ajquery.cjs",
"ajquery.min.cjs",
"ajquery.mjs",
"ajquery.min.mjs"
"ajquery.js"
],
"scripts": {
"benchmark": "node ./benchmark.js",
"build": "npm run build-all",
"bump": "npm version -m \"chore(release): bump to v%s\"",
"fmt": "npm run prettier",
"lint": "npm run jshint && npm run tsc",
"start": "open http://localhost/example.html && caddy file-server --browse --root .",
"test": "node ./tests/",
"--------": "---------------------------------------",
"build-all": "npm run build-js && npm run build-cjs && npm run build-mjs",
"build-js": "npx -p uglify-js@3 uglifyjs --compress 'assignments' --mangle reserved='[\"$\",\"$$\",\"require\",\"exports\"]' ajquery.js -o ajquery.min.js",
"build-cjs": "npx -p uglify-js@3 uglifyjs --compress 'assignments' --mangle reserved='[\"$\",\"$$\",\"require\",\"exports\"]' ajquery.cjs -o ajquery.min.cjs",
"build-mjs": "npx -p uglify-js@3 uglifyjs --compress 'assignments' --mangle reserved='[\"$\",\"$$\"]' ajquery.mjs -o ajquery.min.mjs",
"jshint": "npx -p jshint@2.x -- jshint -c ./.jshintrc ./ajquery.js ./ajquery.cjs ./ajquery.mjs",
"benchmark": "node benchmark.js",
"prepare": "npm run build",
"prepublish": "npm run reexport-types",
"start": "open example.html",
"prettier": "npx prettier -w '**/*.{js,md,css,html}'",
"reexport-types": "npx -p jswt@1.x -- reexport",
"tsc": "npx -p typescript@5.x -- tsc -p ./jsconfig.json"
"build": "npx uglify-js ajquery.js -o ajquery.min.js",
"test": "node test.js"
},
"repository": {
"type": "git",

View File

@ -1,21 +0,0 @@
"use strict";
let AJQueryDefault = require("../");
let AJQueryExplicit = require("../ajquery.cjs");
if (!AJQueryDefault.$) {
throw new Error("did not export $ correctly");
}
if (!AJQueryDefault.$$) {
throw new Error("did not export $$ correctly");
}
if (AJQueryDefault.$ !== AJQueryExplicit.$) {
throw new Error("exported $s do not match");
}
if (AJQueryDefault.$$ !== AJQueryExplicit.$$) {
throw new Error("exported $$s do not match");
}
console.log(`\x1b[34mPASS\x1b[33m`);

View File

@ -1,12 +0,0 @@
"use strict";
import AJQueryExplicit from "../ajquery.mjs";
if (!AJQueryExplicit.$) {
throw new Error("did not export $ correctly");
}
if (!AJQueryExplicit.$$) {
throw new Error("did not export $$ correctly");
}
console.log(`\x1b[34mPASS\x1b[33m`);

View File

@ -1,109 +0,0 @@
"use strict";
let ChildProcess = require("child_process");
let Fs = require("node:fs/promises");
let Path = require("node:path");
async function main() {
console.info("TAP version 13");
let dirents = await Fs.readdir(__dirname, { withFileTypes: true });
let failures = 0;
let count = 0;
for (let dirent of dirents) {
if (dirent.name === "index.js") {
continue;
}
count += 1;
let direntPath = Path.join(__dirname, dirent.name);
let relPath = Path.relative(".", direntPath);
let success = await handleEach(count, relPath);
if (!success) {
failures += 1;
}
}
let start = 1;
if (count < 1) {
start = 0;
}
let passes = count - failures;
console.info(``);
console.info(`${start}..${count}`);
console.info(`# tests ${count}`);
console.info(`# pass ${passes}`);
console.info(`# fail ${failures}`);
console.info(`# skip 0`);
if (failures !== 0) {
process.exit(1);
}
}
async function handleEach(count, relPath) {
let success = await exec("node", [relPath])
.then(function (result) {
console.info(`ok ${count} - ${relPath}`);
return true;
})
.catch(function (err) {
console.info(`not ok ${count} - ${relPath}`);
if (err.code) {
console.info(` # Error: ${err.code}`);
}
if (err.stderr) {
console.info(` # Stderr: ${err.stderr}`);
}
return false;
});
return success;
}
async function exec(exe, args) {
return new Promise(function (resolve, reject) {
let cmd = ChildProcess.spawn(exe, args);
let stdout = [];
let stderr = [];
cmd.stdout.on("data", function (data) {
stdout.push(data.toString("utf8"));
});
cmd.stderr.on("data", function (data) {
stderr.push(data.toString("utf8"));
});
cmd.on("close", function (code) {
let result = {
code: code,
stdout: stdout.join(""),
stderr: stderr.join(""),
};
if (!code) {
resolve(result);
return;
}
let err = new Error(result.stderr);
Object.assign(err, result);
reject(err);
});
});
}
main()
.then(function () {
process.exit(0);
})
.catch(function (err) {
console.error("Fail:");
console.error(err.stack || err);
process.exit(1);
});