Skip to content

Commit

Permalink
improve guard and fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 9, 2022
1 parent 81bacc0 commit 190bc2c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/scriptlets/set-local-storage-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ import {
/* eslint-enable max-len */

export function setLocalStorageItem(source, key, value) {
if (!key || (!value && value !== '')) {
// eslint-disable-next-line no-console
const log = console.log.bind(console);

if (typeof key === 'undefined') {
log('Item key should be specified.');
return;
}

if (typeof value === 'undefined') {
log('Item value should be specified.');
return;
}

Expand Down
11 changes: 10 additions & 1 deletion src/scriptlets/set-session-storage-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ import {
/* eslint-enable max-len */

export function setSessionStorageItem(source, key, value) {
if (!key || (!value && value !== '')) {
// eslint-disable-next-line no-console
const log = console.log.bind(console);

if (typeof key === 'undefined') {
log('Item key should be specified.');
return;
}

if (typeof value === 'undefined') {
log('Item value should be specified.');
return;
}

Expand Down
15 changes: 11 additions & 4 deletions src/scriptlets/trusted-set-local-storage-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,24 @@ import {
* example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$currentDate$')
* ```
*
* 4. Set item without key or value
* 4. Set item without value
* ```
* example.org#%#//scriptlet('trusted-set-local-storage-item', '', '2644')
*
* example.org#%#//scriptlet('trusted-set-local-storage-item', 'ppu_main_none', '')
* ```
*/
/* eslint-enable max-len */

export function trustedSetLocalStorageItem(source, key, value) {
if (!key || (!value && value !== '')) {
// eslint-disable-next-line no-console
const log = console.log.bind(console);

if (typeof key === 'undefined') {
log('Item key should be specified.');
return;
}

if (typeof value === 'undefined') {
log('Item value should be specified.');
return;
}

Expand Down

0 comments on commit 190bc2c

Please sign in to comment.