react-jsbox
Advanced tools
Comparing version 0.0.24 to 0.0.25
{ | ||
"name": "react-jsbox", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "A Custom React Renderer for writing JSBox apps in React.", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"author": "Eva1ent", | ||
"repository": "github:186c0/react-jsbox-renderer", | ||
"repository": "github:Nicify/react-jsbox-renderer", | ||
"babel": { | ||
@@ -22,0 +22,0 @@ "presets": [ |
@@ -6,3 +6,5 @@ const DEBUG = false | ||
global.console.log = hookArgs(console.log, (...args) => | ||
args.map(arg => JSON.parse(JSON.stringify(arg, getCircularReplacer()))) | ||
args.map(arg => | ||
arg === undefined ? 'undefined' : JSON.stringify(arg, getCircularReplacer()) | ||
) | ||
) | ||
@@ -17,3 +19,3 @@ } | ||
export const { now } = Date | ||
export const {now} = Date | ||
@@ -52,3 +54,3 @@ // Based on react-three-fiber ((c) 2019 Paul Henschel, MIT). | ||
].reduce((acc, prop) => { | ||
let { [prop]: _, ...rest } = acc | ||
let {[prop]: _, ...rest} = acc | ||
return rest | ||
@@ -75,4 +77,6 @@ }, newProps) | ||
let args = argsGetter.apply(this, arguments) | ||
for (let i = 0; i < args.length; ++i) { | ||
arguments[i] = args[i] | ||
if (Array.isArray(args)) { | ||
for (let i = 0; i < args.length; ++i) { | ||
arguments[i] = args[i] | ||
} | ||
} | ||
@@ -79,0 +83,0 @@ return originalFn.apply(this, arguments) |
import {useEffect, useState} from 'react' | ||
const useCache = (key, initialValue, raw) => { | ||
const useCache = (key, initialValue) => { | ||
const [state, setState] = useState(() => { | ||
try { | ||
const cacheValue = $cache.get(key) | ||
if (typeof cacheValue !== 'string') { | ||
$cache.set(key, raw ? String(initialValue) : JSON.stringify(initialValue)) | ||
return initialValue | ||
} else { | ||
return raw ? cacheValue : JSON.parse(cacheValue || 'null') | ||
} | ||
} catch { | ||
const cacheValue = $cache.get(key) | ||
if (cacheValue === undefined) { | ||
$cache.set(key, initialValue) | ||
return initialValue | ||
} | ||
return cacheValue | ||
}) | ||
@@ -20,4 +15,3 @@ | ||
try { | ||
const serializedState = raw ? String(state) : JSON.stringify(state) | ||
$cache.set(key, serializedState) | ||
$cache.set(key, state) | ||
} catch {} | ||
@@ -24,0 +18,0 @@ }) |
Sorry, the diff of this file is too big to display
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
101096
767