diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f3683e..f028e52 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,10 +14,10 @@ jobs: name: Release runs-on: ubuntu-latest permissions: - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues pull-requests: write # to be able to comment on released pull requests - id-token: write # OIDC for npm trusted publishing (+ provenance) + id-token: write # OIDC for npm trusted publishing (+ provenance) steps: - name: Checkout repository uses: actions/checkout@v7 diff --git a/README.md b/README.md index 9c733d6..7a677b6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # attr-accept + > JavaScript implementation of the "accept" attribute for HTML5 `` [![npm](https://img.shields.io/npm/v/attr-accept.svg?style=flat-square)](https://www.npmjs.com/package/attr-accept) @@ -9,44 +10,63 @@ See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-ac Ships as both ES modules and CommonJS with bundled TypeScript type definitions. ## Installation + ```sh npm install --save attr-accept ``` ## Usage + ```javascript import accept from "attr-accept"; -accept({ - name: "my file.png", - type: "image/png" -}, "image/*"); // => true +accept( + { + name: "my file.png", + type: "image/png" + }, + "image/*" +); // => true -accept({ - name: "my file.json", - type: "application/json" -}, "image/*"); // => false +accept( + { + name: "my file.json", + type: "application/json" + }, + "image/*" +); // => false -accept({ - name: "my file.srt", - type: "" -}, ".srt"); // => true +accept( + { + name: "my file.srt", + type: "" + }, + ".srt" +); // => true ``` You can also pass multiple mime types as a comma delimited string or array. + ```javascript -accept({ - name: "my file.json", - type: "application/json" -}, "application/json,video/*"); // => true - -accept({ - name: "my file.json", - type: "application/json" -}, ["application/json", "video/*"]); // => true +accept( + { + name: "my file.json", + type: "application/json" + }, + "application/json,video/*" +); // => true + +accept( + { + name: "my file.json", + type: "application/json" + }, + ["application/json", "video/*"] +); // => true ``` In a CommonJS environment, use `require` instead: + ```javascript const accept = require("attr-accept"); ``` diff --git a/package.json b/package.json index d626b61..6adf834 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "lint": "oxlint", "lint:fix": "oxlint --fix", "lint:type-aware": "oxlint --type-aware", - "format": "oxfmt \"src/**/*.ts\" \"*.ts\"", - "format:check": "oxfmt --check \"src/**/*.ts\" \"*.ts\"", + "format": "oxfmt .", + "format:check": "oxfmt --check .", "pretest:cov": "npm run type-check && npm run lint && npm run format:check", "test": "vitest", "test:cov": "vitest run --coverage",