@slipmatio/toolbelt
Advanced tools
Comparing version 0.1.2 to 0.2.0
# Changelog | ||
## 0.2.0 (2024-01-05) | ||
- Feat: added `getNextPath` | ||
- Refactor: refactored internals | ||
- Chore: bumped deps. | ||
## 0.1.2 (2023-07-17) | ||
@@ -4,0 +10,0 @@ |
@@ -9,5 +9,10 @@ /** | ||
*/ | ||
export declare function getCookie(name: string): string | null; | ||
export declare function getCookie(name: string): string; | ||
/** | ||
* Helper for figuring our ?next= query param in a safe way. | ||
*/ | ||
export declare function getNextPath(): string; | ||
/** | ||
* Checks whether the given Storage is available and usable. | ||
@@ -14,0 +19,0 @@ */ |
@@ -1,1 +0,54 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(o){let t;o==="localStorage"?t=window.localStorage:t=window.sessionStorage;try{const e="__storage_test__";return t.setItem(e,e),t.removeItem(e),!0}catch(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0}}function i(o){let t="";if(document.cookie&&document.cookie!==""){const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const r=e[n].trim();if(r.substring(0,o.length+1)===o+"="){t=decodeURIComponent(r.substring(o.length+1));break}}}return t.length>0?t:null}function l(o){const t=document;try{const e=document.createElement("input");return e.setAttribute("style","opacity:0;"),e.setAttribute("value",o),t.body.appendChild(e),e.select(),t.execCommand("copy"),t.body.removeChild(e),!0}catch{return!1}}exports.copyToClipboard=l;exports.getCookie=i;exports.storageAvailable=c; | ||
import { useRoute as c } from "vue-router"; | ||
function s(o) { | ||
let t; | ||
o === "localStorage" ? t = window.localStorage : t = window.sessionStorage; | ||
try { | ||
const e = "__storage_test__"; | ||
return t.setItem(e, e), t.removeItem(e), !0; | ||
} catch (e) { | ||
return e instanceof DOMException && // everything except Firefox | ||
(e.code === 22 || // Firefox | ||
e.code === 1014 || // test name field too, because code might not be present | ||
// everything except Firefox | ||
e.name === "QuotaExceededError" || // Firefox | ||
e.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored | ||
t && t.length !== 0; | ||
} | ||
} | ||
function l(o) { | ||
let t = ""; | ||
if (document.cookie && document.cookie !== "") { | ||
const e = document.cookie.split(";"); | ||
for (let n = 0; n < e.length; n++) { | ||
const r = e[n].trim(); | ||
if (r.substring(0, o.length + 1) === o + "=") { | ||
t = decodeURIComponent(r.substring(o.length + 1)); | ||
break; | ||
} | ||
} | ||
} | ||
return t.length > 0 ? t : null; | ||
} | ||
function a(o) { | ||
const t = document; | ||
try { | ||
const e = document.createElement("input"); | ||
return e.setAttribute("style", "opacity:0;"), e.setAttribute("value", o), t.body.appendChild(e), e.select(), t.execCommand("copy"), t.body.removeChild(e), !0; | ||
} catch { | ||
return !1; | ||
} | ||
} | ||
function i(o) { | ||
return typeof o == "string"; | ||
} | ||
function d() { | ||
const o = c(); | ||
let t = "/"; | ||
return o.query && o.query.next && i(o.query.next) && o.query.next.startsWith("/") && (t = o.query.next), t; | ||
} | ||
export { | ||
a as copyToClipboard, | ||
l as getCookie, | ||
d as getNextPath, | ||
s as storageAvailable | ||
}; |
{ | ||
"name": "@slipmatio/toolbelt", | ||
"version": "0.1.2", | ||
"type": "module", | ||
"version": "0.2.0", | ||
"main": "dist/toolbelt.js", | ||
@@ -19,21 +20,25 @@ "module": "dist/toolbelt.mjs", | ||
"dev": "DEBUG=0 vite", | ||
"build": "DEBUG=0 vue-tsc && vite build", | ||
"build": "DEBUG=0 vue-tsc --build --force && vite build", | ||
"test": "DEBUG=0 vitest", | ||
"test:e2e": "DEBUG=0 playwright test --ui", | ||
"test:ci-e2e": "DEBUG=0 playwright test", | ||
"coverage": "DEBUG=0 vitest run --coverage" | ||
"coverage": "DEBUG=0 vitest run --coverage", | ||
"type-check": "DEBUG=0 vue-tsc --build --force" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "1.36.1", | ||
"@types/node": "20.4.2", | ||
"@vitejs/plugin-vue": "4.2.3", | ||
"@vitest/coverage-v8": "0.33.0", | ||
"@vue/test-utils": "2.4.0", | ||
"happy-dom": "10.3.2", | ||
"typescript": "5.1.6", | ||
"vite": "4.4.4", | ||
"vite-plugin-dts": "3.2.0", | ||
"vitest": "0.33.0", | ||
"vue": "3.3.4", | ||
"vue-tsc": "1.8.5" | ||
"@playwright/test": "1.40.1", | ||
"@tsconfig/node20": "20.1.2", | ||
"@types/node": "20.10.6", | ||
"@vitejs/plugin-vue": "5.0.2", | ||
"@vitest/coverage-v8": "1.1.3", | ||
"@vue/test-utils": "2.4.3", | ||
"@vue/tsconfig": "0.5.1", | ||
"happy-dom": "12.10.3", | ||
"typescript": "5.3.3", | ||
"vite": "5.0.11", | ||
"vite-plugin-dts": "3.7.0", | ||
"vitest": "1.1.3", | ||
"vue": "3.4.5", | ||
"vue-router": "4.2.5", | ||
"vue-tsc": "1.8.27" | ||
}, | ||
@@ -40,0 +45,0 @@ "files": [ |
@@ -8,2 +8,3 @@ # Slipmat Toolbelt | ||
## Features | ||
### Browser | ||
@@ -15,2 +16,6 @@ | ||
### Vue | ||
- `getNextPath(): string` - returns the value of `?next` query param or `/` | ||
## Installation | ||
@@ -17,0 +22,0 @@ |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
7391
76
48
Yes
15
2