-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Settings for editors and IDEs. | ||
root = true | ||
|
||
# Settings for any file. | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Unlinted files and folders. | ||
|
||
# Generated docs, bundles and type definitions. | ||
docs/ | ||
dist/ | ||
types/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @ts-check | ||
/* eslint-env node */ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* An object with ESLint options. | ||
* @type {import('eslint').Linter.Config} | ||
*/ | ||
const options = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 2021, | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:prettier/recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
}; | ||
|
||
module.exports = options; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# File attributes for Git repository. | ||
# References at https://git-scm.com/docs/gitattributes. | ||
|
||
# Handle files as text and ensure Unix line endings. | ||
* text=auto eol=lf | ||
|
||
# Ignore differences on NPM's lockfile. | ||
# Since version 5.7.0, NPM automatically handles merge conflicts. | ||
package-lock.json -diff |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: 'Setup' | ||
description: "Setups Node.js and npm to run GitHub Actions' jobs." | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Setup Node.js' | ||
uses: 'actions/setup-node@v3' | ||
with: | ||
node-version: '20.x' | ||
cache: 'npm' | ||
cache-dependency-path: '**/package-lock.json' | ||
|
||
- name: 'Keep npm cache for future workflows' | ||
uses: 'actions/cache@v3' | ||
with: | ||
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}" | ||
path: '~/.npm' | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: 'Install dependencies' | ||
run: 'npm ci' | ||
shell: 'bash' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 'Continuous Integrations' | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
jobs: | ||
lint: | ||
name: 'Run ESLint and Prettier' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: 'Checkout the repository' | ||
uses: 'actions/checkout@v3' | ||
|
||
- name: 'Setup Node.js and npm' | ||
uses: './.github/actions/setup' | ||
|
||
- name: 'Execute the lint script' | ||
run: 'npm run lint' | ||
|
||
|
||
test: | ||
name: 'Run unit tests with Jest' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: 'Checkout the repository' | ||
uses: 'actions/checkout@v3' | ||
|
||
- name: 'Setup Node.js and npm' | ||
uses: './.github/actions/setup' | ||
|
||
- name: 'Execute the test script' | ||
run: 'npm run test' | ||
|
||
bundle: | ||
name: 'Bundle package with Rollup.js' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: 'Checkout the repository' | ||
uses: 'actions/checkout@v3' | ||
|
||
- name: 'Setup Node.js and npm' | ||
uses: './.github/actions/setup' | ||
|
||
- name: 'Execute the build script' | ||
run: 'npm run build' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Unversioned files and folders. | ||
|
||
.DS_Store | ||
node_modules/ | ||
npm-shrinkwrap.json | ||
yarn.lock | ||
.pnp.* | ||
.yarn/ | ||
.yarnrc | ||
.yarnrc.yaml | ||
pnpm-lock.yaml | ||
pnpm-workspace.yaml | ||
pnpmfile.js | ||
*.log | ||
*.log.* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Unlinted files and folders. | ||
|
||
# Generated docs, bundles and type definitions. | ||
docs/ | ||
dist/ | ||
types/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 pgEdge | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Prest Client | ||
|
||
[![Continuous Integrations](https://github.com/pgEdge/prest-client/actions/workflows/continuous-integrations.yaml/badge.svg?branch=main)](https://github.com/pgEdge/prest-client/actions/workflows/continuous-integrations.yaml) | ||
[![License](https://badgen.net/github/license/pgEdge/prest-client)](./LICENSE) | ||
[![Package tree-shaking](https://badgen.net/bundlephobia/tree-shaking/prest-client)](https://bundlephobia.com/package/prest-client) | ||
[![Package minified & gzipped size](https://badgen.net/bundlephobia/minzip/prest-client)](https://bundlephobia.com/package/prest-client) | ||
[![Package dependency count](https://badgen.net/bundlephobia/dependency-count/reactprest-client)](https://bundlephobia.com/package/prest-client) | ||
|
||
## Installation | ||
|
||
This library is published in the NPM registry and can be installed using any compatible package manager. | ||
|
||
```sh | ||
npm install prest-client --save | ||
|
||
# For Yarn, use the command below. | ||
yarn add prest-client | ||
``` | ||
|
||
### Installation from CDN | ||
|
||
This module has an UMD bundle available through JSDelivr and Unpkg CDNs. | ||
|
||
```html | ||
<!-- For UNPKG use the code below. --> | ||
<script src="https://unpkg.com/prest-client"></script> | ||
|
||
<!-- For JSDelivr use the code below. --> | ||
<script src="https://cdn.jsdelivr.net/npm/prest-client"></script> | ||
|
||
<script> | ||
// UMD module is exposed through the "prestClient" global variable. | ||
console.log(prestClient); | ||
</script> | ||
``` | ||
|
||
## Documentation | ||
|
||
[Documentation generated from source files by Typedoc](./docs/README.md). | ||
|
||
## License | ||
|
||
Released under [MIT License](./LICENSE). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*! | ||
* prest-client v0.0.0 | ||
* (c) pgEdge | ||
* Released under the MIT License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Check if a string is a valid username based on the defined criteria. | ||
* @param value - The string to be validated. | ||
* @returns Whether the string is a valid username. | ||
*/ | ||
var isValidUsername = function (value) { | ||
var usernameRegex = /^[a-zA-Z][\w_]+$/; | ||
return usernameRegex.test(value) && value.length >= 3 && value.length <= 15; | ||
}; | ||
/** | ||
* Parse a string into a safe integer, throwing an error if the parsing fails. | ||
* @param value - The string to be parsed. | ||
* @returns The parsed integer value. | ||
*/ | ||
var parseSafeInt = function (value) { | ||
var parsedValue = parseInt(value, 10); | ||
if (Number.isNaN(parsedValue)) { | ||
throw new Error("Invalid integer: ".concat(value)); | ||
} | ||
return parsedValue; | ||
}; | ||
|
||
exports.isValidUsername = isValidUsername; | ||
exports.parseSafeInt = parseSafeInt; | ||
//# sourceMappingURL=index.cjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*! | ||
* prest-client v0.0.0 | ||
* (c) pgEdge | ||
* Released under the MIT License. | ||
*/ | ||
|
||
/** | ||
* Check if a string is a valid username based on the defined criteria. | ||
* @param value - The string to be validated. | ||
* @returns Whether the string is a valid username. | ||
*/ | ||
var isValidUsername = function (value) { | ||
var usernameRegex = /^[a-zA-Z][\w_]+$/; | ||
return usernameRegex.test(value) && value.length >= 3 && value.length <= 15; | ||
}; | ||
/** | ||
* Parse a string into a safe integer, throwing an error if the parsing fails. | ||
* @param value - The string to be parsed. | ||
* @returns The parsed integer value. | ||
*/ | ||
var parseSafeInt = function (value) { | ||
var parsedValue = parseInt(value, 10); | ||
if (Number.isNaN(parsedValue)) { | ||
throw new Error("Invalid integer: ".concat(value)); | ||
} | ||
return parsedValue; | ||
}; | ||
|
||
export { isValidUsername, parseSafeInt }; | ||
//# sourceMappingURL=index.mjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.