Skip to content

Commit

Permalink
chore(release): v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcachips authored and Marcachips committed Jun 13, 2023
1 parent 4d7d199 commit 6bd6430
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.5.1](https://github.com/klientjs/core/compare/1.5.0...1.5.1) (2023-06-13)


### Features

* add 'has' method in bag class ([18353fd](https://github.com/klientjs/core/commit/18353fda1537947622fd85ea68bc68e8c7d37812))

# [1.5.0](https://github.com/klientjs/core/compare/1.4.0...1.5.0) (2023-06-12)


Expand Down
1 change: 1 addition & 0 deletions dist/cjs/services/bag/bag.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class Bag implements BagItems, Watchable {
callback: WatchCallback<unknown, unknown>;
deep: boolean;
}[]>;
has(path: string): boolean;
get(path: string): any;
all(): import("../../toolbox/object").AnyObject;
set(path: string, value: unknown): this;
Expand Down
3 changes: 3 additions & 0 deletions dist/cjs/services/bag/bag.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Bag {
get watchers() {
return (0, watch_1.getWatchers)(this);
}
has(path) {
return objectPath.get(this, path) !== undefined;
}
get(path) {
return objectPath.get(this.all(), path);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/cjs/services/bag/watch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare type WatcherItem = {
callback: WatchCallback;
deep: boolean;
};
export declare function getWatchers(wachtable: Watchable): Record<string, WatcherItem[]>;
export declare function getWatchers(watchable: Watchable): Record<string, WatcherItem[]>;
export declare function watch<T extends Watchable>(watchable: T, path: string, onChange: WatchCallback, deep: boolean): T;
export declare function unwatch<T extends Watchable>(watchable: T, path: string, onChange: WatchCallback): T;
export declare function invokeWatchers<T extends Watchable>(watchable: T, next: object, prev: object): T;
Expand Down
10 changes: 5 additions & 5 deletions dist/cjs/services/bag/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ const objectPath = require("object-path");
const deepDiff = require("deep-diff");
const instances = {};
const watchers = {};
function getInstanceId(wachtable) {
function getInstanceId(watchable) {
const ids = Object.keys(instances);
let id = null;
for (let i = 0, len = ids.length; i < len; i += 1) {
if (instances[ids[i]] === wachtable) {
if (instances[ids[i]] === watchable) {
id = ids[i];
break;
}
}
if (id === null) {
id = Math.random().toString(36).substring(2);
instances[id] = wachtable;
instances[id] = watchable;
}
return id;
}
function getWatchers(wachtable) {
const id = getInstanceId(wachtable);
function getWatchers(watchable) {
const id = getInstanceId(watchable);
if (!watchers[id]) {
watchers[id] = {};
}
Expand Down
1 change: 1 addition & 0 deletions dist/esm/services/bag/bag.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class Bag implements BagItems, Watchable {
callback: WatchCallback<unknown, unknown>;
deep: boolean;
}[]>;
has(path: string): boolean;
get(path: string): any;
all(): import("../../toolbox/object").AnyObject;
set(path: string, value: unknown): this;
Expand Down
3 changes: 3 additions & 0 deletions dist/esm/services/bag/bag.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default class Bag {
get watchers() {
return getWatchers(this);
}
has(path) {
return objectPath.get(this, path) !== undefined;
}
get(path) {
return objectPath.get(this.all(), path);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/esm/services/bag/watch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare type WatcherItem = {
callback: WatchCallback;
deep: boolean;
};
export declare function getWatchers(wachtable: Watchable): Record<string, WatcherItem[]>;
export declare function getWatchers(watchable: Watchable): Record<string, WatcherItem[]>;
export declare function watch<T extends Watchable>(watchable: T, path: string, onChange: WatchCallback, deep: boolean): T;
export declare function unwatch<T extends Watchable>(watchable: T, path: string, onChange: WatchCallback): T;
export declare function invokeWatchers<T extends Watchable>(watchable: T, next: object, prev: object): T;
Expand Down
10 changes: 5 additions & 5 deletions dist/esm/services/bag/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import * as objectPath from 'object-path';
import * as deepDiff from 'deep-diff';
const instances = {};
const watchers = {};
function getInstanceId(wachtable) {
function getInstanceId(watchable) {
const ids = Object.keys(instances);
let id = null;
for (let i = 0, len = ids.length; i < len; i += 1) {
if (instances[ids[i]] === wachtable) {
if (instances[ids[i]] === watchable) {
id = ids[i];
break;
}
}
if (id === null) {
id = Math.random().toString(36).substring(2);
instances[id] = wachtable;
instances[id] = watchable;
}
return id;
}
export function getWatchers(wachtable) {
const id = getInstanceId(wachtable);
export function getWatchers(watchable) {
const id = getInstanceId(watchable);
if (!watchers[id]) {
watchers[id] = {};
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"axios",
"sdk"
],
"version": "1.5.0",
"version": "1.5.1",
"license": "MIT",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
Expand Down

0 comments on commit 6bd6430

Please sign in to comment.