Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ All React utilities, components and hooks are 100% SSR ready.
import { useMatchMedia } from '@krutoo/utils/react';

function App() {
const isMobile = useMatchMedia('(max-width: 1024px)');
const mobile = useMatchMedia('(max-width: 1024px)');

return <>...</>;
}
Expand All @@ -61,22 +61,12 @@ import * as utils from '@krutoo/utils/rspack';
export default {
entry: './src/index.ts',
plugins: [
// typescript support (with alias from "paths" of tsconfig and `resolve.alias` extending)
utils.pluginTypeScript(),

// css and css-modules support ("css-loader" must be added to your project)
utils.pluginCSS(),

// html file will be added to bundle
utils.pluginHTML({ template: './src/index.html' }),

// import file source code by `?raw` query or `with { type: 'text' }`
utils.pluginHTML(),
utils.pluginRawImport(),

// "public" folder will be copied to bundle
utils.pluginPublicFiles(),

// ...and other
// ...and more
],
};
```
Expand All @@ -102,8 +92,6 @@ Repo description and how to work with

Test for module `{path}/{module}.ts` should be placed in `{path}/__test__/{module}.test.ts`.

By default test environment is just Node.js environment.

For write tests with simulating browser environment you need to name test file like `*.web.test.ts`.

### Exports convention
Expand Down
27 changes: 0 additions & 27 deletions docs/docs/dom/find-ancestor.mdx

This file was deleted.

29 changes: 0 additions & 29 deletions src/dom/__test__/find-ancestor.web.test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/dom/find-ancestor.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/dom/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './find-closest.ts';
export * from './find-ancestor.ts';
export * from './get-positioned-parent-offset.ts';
export * from './is-scrollable.ts';
12 changes: 6 additions & 6 deletions src/store/create-store.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import type { Store } from './types.ts';

/**
* Creates "nano store".
* Creates "store" - subscribable state container.
* @param initialValue Initial value.
* @returns Nano store.
* @returns Store.
*/
export function createStore<T>(initialValue: T): Store<T> {
const listeners = new Set<VoidFunction>();

let currentValue: T = initialValue;
let value: T = initialValue;

return {
get(): T {
return currentValue;
return value;
},

set(nextValue: T): void {
if (Object.is(currentValue, nextValue)) {
if (Object.is(value, nextValue)) {
return;
}

currentValue = nextValue;
value = nextValue;

for (const listener of listeners) {
listener();
Expand Down
2 changes: 1 addition & 1 deletion src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export interface Subscribable {
}

/**
* "Nano store" - subscribable state container.
* "Store" - subscribable state container.
*/
export interface Store<T> extends Subscribable, StateContainer<T> {}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"noUnusedLocals": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
Expand Down
Loading