Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gosolivs committed May 10, 2019
0 parents commit 21b6b4d
Show file tree
Hide file tree
Showing 11 changed files with 8,886 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@logux/eslint-config/browser",
"rules": {
"node/no-unpublished-require": "off",
"es5/no-es6-static-methods": "off",
"node/no-missing-require": "off",
"func-style": "off"
}
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
npm-debug.log
yarn-error.log

api.md
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.editorconfig

node_modules/
npm-debug.log
yarn-error.log
yarn.lock

api.md
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 0.1
* Initial release.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright 2019 Ivan Menshykov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# storeon-cross-tab

<img src="https://storeon.github.io/storeon/logo.svg" align="right"
alt="Storeon logo by Anton Lovchikov" width="160" height="142">

## LICENSE

MIT
Binary file added example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Storeon module to update state at different browser tabs
* @param {Object} config The config object
* @param {String} [config.key = 'storeon-crosstab'] The default key
* @param {Boolean} [config.skipInit = true] Skip init event
* @return {Function} Storeon callback module
*/
var crossTab = function (config) {
config = config || {}

var key = config.key || 'storeon-crosstab'
var skipInit = config.skipInit || true

return function (store) {
store.on('crosstab', function (_, state) {
return state
})

store.on('@changed', function (state, event) {
if (skipInit) return skipInit = false

try {
localStorage.setItem(key, JSON.stringify(state))
} catch (e) {}
})

window.addEventListener('storage', function (event) {
store.dispatch('crosstab', JSON.parse(event.newValue))
})
}
}

module.exports = crossTab
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "cross-tab",
"version": "0.1.0",
"description": "Module for storeon to update data at different browser tabs",
"main": "index.js",
"author": "Ivan Solovev <[email protected]>",
"license": "MIT",
"scripts": {
"clean": "rimraf api.md",
"lint": "eslint *.js",
"spell": "yarn docs && yaspeller *.md",
"docs": "documentation build *.js -f md -o api.md",
"test": "yarn lint && size-limit && yarn spell"
},
"devDependencies": {
"@logux/eslint-config": "^28.2.1",
"clean-publish": "^1.1.2",
"documentation": "^11.0.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-es5": "^1.3.1",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-import-helpers": "^0.1.4",
"eslint-plugin-jest": "^22.5.1",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-prefer-let": "^1.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^2.2.0",
"lint-staged": "^8.1.6",
"rimraf": "^2.6.3",
"size-limit": "^1.3.1",
"storeon": "^0.8.2",
"yaspeller": "^5.1.0"
},
"size-limit": [
{
"path": "index.js",
"limit": "100 B"
}
],
"lint-staged": {
"*.md": "yaspeller",
"*.js": "eslint"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"yaspeller": {
"lang": "en",
"ignoreCapitalization": true,
"dictionary": [
"storeon",
"versioning"
]
}
}
Loading

0 comments on commit 21b6b4d

Please sign in to comment.