Skip to content

Commit

Permalink
Merge pull request #6 from softberry/config-workflow
Browse files Browse the repository at this point in the history
Config workflow
  • Loading branch information
softberry committed Mar 24, 2024
2 parents 45b52c4 + a618753 commit c7aa0a0
Show file tree
Hide file tree
Showing 25 changed files with 15,283 additions and 4,809 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Operations System Files
.DS_Store
**/.DS_Store
._.DS_Store
**/._.DS_Store

# Logs
logs
*.log
Expand Down Expand Up @@ -117,3 +123,7 @@ dist

# Compiled code
lib/

# Generated files
blurhash_encoder
**/blurhash_encoder
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"cSpell.words": ["blurhash"]
}
74 changes: 45 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Commitizen Friendly][commitizen-img]][commitizen-url]
[![Semantic Release][semantic-release-img]][semantic-release-url]

> My awesome module
> blurhash-map
## Install

Expand All @@ -19,44 +19,60 @@ npm install blurhash-map
## Usage

```ts
import { myPackage } from 'blurhash-map';

myPackage('hello');
//=> 'hello from my package'
import { BlurHashMap, BlurHashMapConfig } from 'blurhash-map';
const config: BlurHashMapConfig = {
assetsRoot: 'assets/images/samples',
hashMapJsonPath: 'test/fixtures/lib/hashmap.json',
imageExtensions: 'jpg,png,jpeg',
components: { x: 4, y: 3 },
};
const blurHashMap = new BlurHashMap(config);
blurHashMap.init();
// Now, there should be files created next to images
// with the same name but having `.hash` suffix. You should commit these files
// to avoid re-generate them next time you run `BlurHashMap`.
```

## API

### myPackage(input, options?)
### BlurHashMap(config)

#### config

Type: `BlurHashMapConfig`

assetsRoot: string; // Required. Where to find the images
hashMapJsonPath: string; // Required. Where to save generated JSON
imageExtensions: Array<string>; // Optional. Define which image files. Default : 'jpg' | 'jpeg' | 'png' | 'bmp' | 'webp'
components?: { x: number; y: number }; // Optional between 1-9. Default {x:4,y:3}. Higher is more detailed blur but longer string

#### input
#### init()

Type: `string`
Initialize `BlurHashMap` asynchronously. Creates `.hash` files and generates `hash-map.json`.

Lorem ipsum.
### generateOrDelete(imageOrHashFilePath: string, skipIfHasHash = false)

#### options
Generates a hash file if image is found. If Image is not found, deletes the `.hash` file of it.

Type: `object`
### getShortPath(file: string): string

##### postfix
Returns the relative path of the given `file` to the `assetsRoot`

Type: `string`
Default: `rainbows`
### async createJson(): Promise<void>

Lorem ipsum.
Creates `hash-map.json` from the found `.hash` files

[build-img]:https://github.com/softberry/blurhash-map/actions/workflows/release.yml/badge.svg
[build-url]:https://github.com/softberry/blurhash-map/actions/workflows/release.yml
[downloads-img]:https://img.shields.io/npm/dt/blurhash-map
[downloads-url]:https://www.npmtrends.com/blurhash-map
[npm-img]:https://img.shields.io/npm/v/blurhash-map
[npm-url]:https://www.npmjs.com/package/blurhash-map
[issues-img]:https://img.shields.io/github/issues/softberry/blurhash-map
[issues-url]:https://github.com/softberry/blurhash-map/issues
[codecov-img]:https://codecov.io/gh/softberry/blurhash-map/branch/main/graph/badge.svg
[codecov-url]:https://codecov.io/gh/softberry/blurhash-map
[semantic-release-img]:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]:https://github.com/semantic-release/semantic-release
[commitizen-img]:https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]:http://commitizen.github.io/cz-cli/
[build-img]: https://github.com/softberry/blurhash-map/actions/workflows/release.yml/badge.svg
[build-url]: https://github.com/softberry/blurhash-map/actions/workflows/release.yml
[downloads-img]: https://img.shields.io/npm/dt/blurhash-map
[downloads-url]: https://www.npmtrends.com/blurhash-map
[npm-img]: https://img.shields.io/npm/v/blurhash-map
[npm-url]: https://www.npmjs.com/package/blurhash-map
[issues-img]: https://img.shields.io/github/issues/softberry/blurhash-map
[issues-url]: https://github.com/softberry/blurhash-map/issues
[codecov-img]: https://codecov.io/gh/softberry/blurhash-map/branch/main/graph/badge.svg
[codecov-url]: https://codecov.io/gh/softberry/blurhash-map
[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]: https://github.com/semantic-release/semantic-release
[commitizen-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]: http://commitizen.github.io/cz-cli/
13 changes: 8 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ module.exports = {
'<rootDir>/src/**/*.ts',
'!<rootDir>/src/types/**/*.ts',
],
globals: {
'ts-jest': {
diagnostics: false,
isolatedModules: true,
},
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: false,
isolatedModules: true,
},
],
},
};
Loading

0 comments on commit c7aa0a0

Please sign in to comment.