Skip to content

Commit

Permalink
docs: small adjustments to comments (#1)
Browse files Browse the repository at this point in the history
Update the documentation in a few places and add a publication workflow.
  • Loading branch information
danieleloscozzese authored Jan 9, 2025
1 parent eb4b880 commit 9d18ba9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Test"

on:
pull_request:
types: [opened, synchronize, reopened]

# Only allow one workflow run at a time per PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
test:
name: "Test"
runs-on: ["ubuntu-latest"]
env:
TZ: "Europe/Rome"
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Set up Node.js"
uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "npm"

- name: "Test the package"
run: npm cit --quiet
timeout-minutes: 5
33 changes: 33 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: "Publish to npm"

on:
release:
types: ["created"]

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm cit
timeout-minutes: 5

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ postTask(() => {
trackEvent("something-happened");
}, "background");
```

## Formats

This package is equally available as ESM and CJS and has a single, default
export.
The code is identical between the formats except on the exporting itself.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2024 Adevinta

declare module "post-task" {
/**
Expand Down
17 changes: 9 additions & 8 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2024 Adevinta

/**
* The priority of the task: these are the priorities of the Scheduler API.
Expand All @@ -12,20 +13,20 @@
* The task will be executed as soon as possible, in idle time, but guaranteed within the timeout.
* @type {PriorityConfigurationFallback}
*/
const priorityIdleTimeouts = Object.freeze({
background: 1000,
"user-visible": 100,
"user-blocking": 50,
const priorityIdleTimeouts = Object.create(null, {
background: { value: 1000, enumerable: true },
"user-visible": { value: 100, enumerable: true },
"user-blocking": { value: 50, enumerable: true },
});

/**
* The timeouts used for setTimeout, which define the delay before the task is executed.
* @type {PriorityConfigurationFallback}
*/
const priorityCallbackDelays = Object.freeze({
background: 150,
"user-visible": 0,
"user-blocking": 0,
const priorityCallbackDelays = Object.create(null, {
background: { value: 150, enumerable: true },
"user-visible": { value: 0, enumerable: true },
"user-blocking": { value: 0, enumerable: true },
});

/** @typedef {() => void} Task */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "post-task",
"version": "1.1.3",
"description": "A polyfill for the Scheduler API with a pre-configured progressively-enhanced function which allows for task division.",
"description": "A polyfill for the Scheduler API with a pre-configured progressively-enhanced function helps to split long-running tasks into chunks.",
"type": "module",
"exports": {
"types": "./index.d.ts",
Expand Down

0 comments on commit 9d18ba9

Please sign in to comment.