Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
added a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed May 29, 2019
1 parent 198154a commit 132d849
Show file tree
Hide file tree
Showing 20 changed files with 4,619 additions and 306 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,json}]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = false
insert_final_newline = false
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 🐛 Bug Report
about: Report a reproducible bug or regression
labels: waiting for assignment
---

<!-- Requirements: PLEASE go through this checklist before opening a new issue -->

* describe expected behavior
* describe actual behavior
* (if applies) describe steps to reproduce it (add some context info e.g. I just restared the PC, I came back after lunch, after few days...)
* (if applies) values like id / url / date / ...
* (if applies / frontend / layout related issues) browser and OS version are a nice to have (use: https://www.whatsmybrowser.org/)
* (if applies / backend) the datetime when the bug occurred (so we can check logs, database entries by date, token expiration(s) at a date etc.)
* (if applies) add the file that created the problem (if the bug is related to a specific file)
* (if applies) specify which user reported this bug to us, so that we can send a message to that user as soon as it is fixed and included in a new release
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: 📑 NEW Feature Request
about: Add / build request of a new feature
labels: waiting for assignment
---

<!-- Requirements: please go through this checklist before opening a new issue -->

* describe expected behavior from a product point of view (specifications document)
* (if applies) link to technical specifications document
* (if applies) post a resume of the brainstorming
* (if applies) link to wire frames / mock ups
* (if applies) describe the new database schema / structure
* (if applies) list current services / features that will be impacted by the new feature
* (if applies) specify which user that asked for this feature, so that we can inform the user when this feature has been released (also so that we see how many users requested this feature)
58 changes: 53 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# chrisweb utilities.js 1.0.0
[![Dependencies](https://david-dm.org/chrisweb/chrisweb-utilities.js/status.svg)](https://david-dm.org/chrisweb/chrisweb-utilities.js)
[![DevDependencies](https://david-dm.org/chrisweb/chrisweb-utilities.js/dev-status.svg)](https://david-dm.org/chrisweb/chrisweb-utilities.js)
[![GitHub release](https://img.shields.io/github/release/chrisweb/chrisweb-utilities.js.svg)](https://github.com/chrisweb/chrisweb-utilities.js/releases)
[![GitHub file size in bytes](https://img.shields.io/github/size/chrisweb/chrisweb-utilities.js/dist/index.esm.js.svg)](https://github.com/chrisweb/chrisweb-utilities.js)
[![Module formats](https://img.shields.io/badge/module%20formats-ESM%20+%20UMD-green.svg)](https://github.com/chrisweb/chrisweb-utilities.js/tree/master/dist)
[![GitHub license](https://img.shields.io/github/license/chrisweb/chrisweb-utilities.js.svg)](https://github.com/chrisweb/chrisweb-utilities.js/blob/master/LICENSE)
[![issues / PRs](https://img.shields.io/badge/issues%20/%20PRs-welcome-green.svg)](https://github.com/chrisweb/chrisweb-utilities.js/issues/new/choose)

# chrisweb utilities.js

Javascript utilities belt for very specific tasks.

Expand All @@ -22,26 +30,66 @@ install the dependencies

`npm install`

to lint the typescript files

`npm run lint`

run the tests

`npm run test`

to build the distributions (es6 module (esm.js) and the UMD version)

`npm run build`

or by using yarn

`yarn build`

## development

in devlopment you can use watch to rebuild every time you edit a typescript file

`npm run watch`

to lint the typescript files
you can also use watch for the test suite

`npm run lint`
`npm run watch:test`

## contributing

Bug reports, tests, fixes, new features and all kind of comments / feedback are welcome 😃
Bug reports, tests, fixes, new features and all kind of comments / feedback are welcome 😃 [Submit a feature request or bug issue](https://github.com/chrisweb/chrisweb-utilities.js/issues/new/choose)

## testing setup notes

I used the [jest testing framework](https://jestjs.io/)

I added the jest typescript types and the [ts-jest package](https://github.com/kulshekhar/ts-jest)

installed dependencies:

`npm install --save-dev jest @types/jest ts-jest`

command to create a basic jest.config.js file:

`npx ts-jest config:init yarn ts-jest config:init`

If you use VSCode, consider using the [vscode jest extension](https://github.com/jest-community/vscode-jest)

Besides reading the official documentation, you can check out this quick [introduction to jest](https://flaviocopes.com/jest/) blog post

## linting setup notes

> we plan to deprecate TSLint and focus our efforts instead on improving ESLint’s TypeScript support

Their [blog post](https://medium.com/palantir/tslint-in-2019-1a144c2317a9) announcing that [TSLint](https://github.com/palantir/tslint) will be deprecated in 2019 and you should switch to [ESLint](https://github.com/eslint/eslint) when TSLint is officially deprecated

TSlint will be deprecated [github ticket](https://github.com/palantir/tslint/issues/4534)

## features

### utilities.log
Colored console log messages for the browser and or nodejs (iojs)
Colored console log messages for the browser and / or nodejs
```
utilities.log('foo', 'bar', 'fontColor:red', 'backgroundColor:blue');
```
Expand Down
4 changes: 2 additions & 2 deletions dist/@types/chrisweb-utilities/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { getTimestamp } from './utilities/datetime';
import { isServer, isClient } from './utilities/platform';
import { getUrlParameters, getUrlParameterByName, replaceUrlParameter } from './utilities/url';
import { decodeUri, encodeUri } from './utilities/uri';
import { arrayRemove } from './utilities/array';
import { remove, isArray, includes, find, flat } from './utilities/array';
import { filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders } from './utilities/string';
import { generateUUID } from './utilities/uuid';
import { removeElements } from './utilities/html';
import { log } from './utilities/log';
declare const version = "1.0.0";
export { version, getTimestamp, isServer, isClient, getUrlParameters, getUrlParameterByName, replaceUrlParameter, decodeUri, encodeUri, arrayRemove, filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders, generateUUID, removeElements, log };
export { version, getTimestamp, isServer, isClient, getUrlParameters, getUrlParameterByName, replaceUrlParameter, decodeUri, encodeUri, remove, isArray, includes, find, flat, filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders, generateUUID, removeElements, log };
23 changes: 21 additions & 2 deletions dist/@types/chrisweb-utilities/utilities/array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,24 @@
* array related functions
*
*/
declare const arrayRemove: (array: string[], removeMe: string) => void;
export { arrayRemove };
declare const remove: (array: string[], removeMe: string) => void;
declare const isArray: (input: any) => boolean;
declare global {
interface Array<T> {
includes(valueToFind: string, fromIndex?: number): boolean;
}
}
declare const includes: (inputArray: [], valueToFind: string, fromIndex?: number) => boolean;
declare const find: (inputArray: [], predicate: any, args: any) => {};
declare global {
interface Array<T> {
flat(depth: number): [];
}
}
/**
*
* array flat polyfill, if depth is unknow set it to "Infinity"
*
*/
declare const flat: (inputArray: [], depth: any) => [];
export { remove, isArray, includes, find, flat };
4 changes: 2 additions & 2 deletions dist/@types/chrisweb-utilities/utilities/uri.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* decode uri
*
*/
declare const decodeUri: (uri: string) => string;
declare const decodeUri: (inputString: string) => string;
/**
*
* encode uri
*
*/
declare const encodeUri: (uri: string) => string;
declare const encodeUri: (inputString: string) => string;
export { decodeUri, encodeUri };
4 changes: 3 additions & 1 deletion dist/@types/chrisweb-utilities/utilities/url.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* get url parameters
*
*/
declare const getUrlParameters: (query?: string) => string[];
declare const getUrlParameters: (query?: string) => {
[s: string]: string;
};
/**
*
* URL utility to get a parameter by name from an URL
Expand Down
Loading

0 comments on commit 132d849

Please sign in to comment.