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
15 changes: 0 additions & 15 deletions .babelrc.js

This file was deleted.

15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

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

[*.md]
trim_trailing_whitespace = false
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

66 changes: 0 additions & 66 deletions .eslintrc.js

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-prefix='~'
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/*.html
**/*.css
**/*.md
docs/lib/**
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"tabWidth": 2,
"useTabs": false,
"printWidth": 120,
"singleQuote": true,
"semi": true,
"trailingComma": "none",
"singleAttributePerLine": false
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "editorconfig.editorconfig"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.enable": true,
"eslint.run": "onType",
"eslint.validate": ["javascript", "html"]
}
8 changes: 8 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"languages": {
"JavaScript": {
"formatter": "prettier",
"format_on_save": "on"
}
}
}
74 changes: 66 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,72 @@
# CHANGELOG

## v3.0.0 (2025-06-18)

### BREAKING CHANGES

#### Switch to ES modules and named exports

The `WebStorage` module is now exclusively available as an ES module (ESM), aligning with the modern JavaScript module standard. Additionally, it is no longer the default export — you must import it using a named import.

**v2.x.x**
```js
import WebStorage from '@georapbox/web-storage';
```

**v3.x.x**
```js
import { WebStorage } from '@georapbox/web-storage';
```

#### API methods return [value, error] tuples

All API methods now return `[value, error]` tuple-like values instead of accepting error callbacks. This allows developers to handle errors in a clean, synchronous style without using `try/catch` or providing callbacks. For example:

**v2.x.x**
```js
const value = storage.getItem('key', value, (err) => {
console.error(err);
});
```

**v3.x.x**
```js
const [value, error] = storage.getItem('key', value);

if (error) {
console.error(error);
}
```

#### Removed noop storage fallback

In previous versions, if `localStorage` or `sessionStorage` was unavailable (e.g., due to privacy settings or Safari private mode), a silent in-memory fallback was used that mimicked the Storage API. This allowed methods like `setItem()` to return success even though no actual data was stored.

This behavior has been removed to improve transparency and correctness. As of v3.0.0:

- No fallback is used.
- Errors are captured and returned via the `[_, error]` tuple-like value.
- Developers can use `WebStorage.isAvailable()` for feature detection, or gracefully handle errors based on method output.

This ensures failures are explicit and prevents false assumptions about persistence.

### NEW FEATURES

#### Type declarations for TypeScript

Export type declaration files (`.d.ts`) for TypeScript users, ensuring better type safety and autocompletion support in TypeScript projects.

### INTERNAL CHANGES

- Update Node.js version requirement and dev dependencies to the latest versions.
- Drop Jest in favor of @web/test-runner and Playwright for testing.
- Drop rollup in favor of esbuild for bundling.

## v2.1.0 (2021-01-26)

- Generate minified versions for ESM and CommonJS exported bubdles.

### Internal changes
### INTERNAL CHANGES

- Replace Mocha with Jest as testing framework.
- Replace Travis CI with Github actions.
Expand All @@ -21,21 +83,17 @@

**v1.x.x**
```js
WebStorage.createInstance({
driver: window.localStorage
})
new WebStorage({ driver: window.localStorage })
```

**v2.x.x**
```js
WebStorage.createInstance({
driver: 'localStorage'
})
new WebStorage({ driver: 'localStorage' })
```
- `WebStorage.isAvailable` static method, as of v2.x, accepts "localStorage" or "sessionStorage" strings as arguments.
- On initialization the library **throws** if `driver` option is anything other than "localStorage" or "sessionStorage" and if `keyPrefix` option is not of type `String`.

### OTHER CHANGES
### INTERNAL CHANGES

- Keep `devDependencies` up to date.

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 George Raptis
Copyright (c) 2018-present George Raptis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading