Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-optimize-service

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-optimize-service - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 1.1.4
* [#24: Update dependencies.](https://github.com/haensl/google-optimize-service/issues/24)
* Externalize `@babel/runtime` for ESM and CJS bundle.
* Automate Github release.
## 1.1.3

@@ -2,0 +7,0 @@ * [#22: Update dependencies.](https://github.com/haensl/google-optimize-service/issues/22)

1

lib/google-optimize-service.cjs.js

@@ -0,2 +1,3 @@

// https://github.com/haensl/google-optimize-service#readme v1.1.4 Copyright 2020 HP Dietz
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("querystring"));const t={localStorage:"local",sessionStorage:"session"},o={autopersist:!0,fields:["variant"],key:"optimize",location:{search:""},storage:null,storagePreference:t.localStorage},s=e=>{if(Array.isArray(e)&&e.reduce((e,r)=>e&&"string"==typeof r,!0))o.fields=e.slice();else if(e)throw new TypeError("Invalid parameter. Expected newFields to be Array of strings.");return o.fields.slice()},n=e=>{if("boolean"==typeof e)o.autopersist=e;else if(void 0!==e)throw new TypeError("Invalid parameter. Expected shouldAutopersist to be boolean.");return o.autopersist},i=e=>{if("string"==typeof e)o.key=e;else if(e)throw new TypeError("Invalid parameter. Expected newKey to be string");return o.key},a=e=>{if(e){if(!("search"in e)||"string"!=typeof e.search)throw new TypeError('Invalid parameter. Expected newLocation to be object with string property "serach".');o.location=e}return{search:o.location.search}},c=e=>{if(e){if("object"!=typeof e)throw new TypeError("Invalid parameter. Expected storage to be object.");["getItem","setItem"].forEach(r=>{if("function"!=typeof e[r])throw new TypeError(`Invalid parameter. Expected storage to implement function ${r}.`)}),o.storage=e}return Object.assign({},o.storage)},l=e=>{if(e){if(!Object.values(t).includes(e))throw new TypeError(`Invalid parameter. Expected newStoragePreference to be on of ${Object.values(t).join(", ")}.`);o.storagePreference=e}return o.storagePreference},p=e=>{if("object"!=typeof e)throw new TypeError("Invalid parameter. Expected opts to be object.");Object.keys(o).forEach(r=>{if(r in e)try{switch(r){case"autopersist":n(e.autopersist);break;case"key":i(e.key);break;case"location":a(e.location);break;case"storage":c(e.storage);break;case"storagePreference":l(e.storagePreference);break;case"fields":s(e.fields)}}catch(e){throw new TypeError(`Invalid option: ${r}.`,e.message)}})},f=()=>{const e={};if(o.location){const t=r.default.parse(o.location.search.replace(/^\?/,""));"utm_expid"in t&&(e.experimentId=t.utm_expid),"utm_referrer"in t&&(e.referrer=t.utm_referrer),(o.fields||[]).forEach(r=>{r in t&&(e[r]=t[r])})}return Object.keys(e).length?e:null},d=(e=u())=>{o.storage&&o.storage.setItem(o.key,JSON.stringify(e))},g=()=>{if(o.location){const e=f();if(e)return e.experimentId}},u=(e=g())=>{const r=(()=>{if(o.storage){const e=o.storage.getItem(o.key);if(e)return JSON.parse(e)}return null})(),t=f(),s=r||{};return t&&!(t.experimentId in s)&&(s[t.experimentId]=t),o.autopersist&&d(s),e?e in s?s[e]:null:Object.keys(s).length?s:null},w=(e=2e3,r=10)=>{document.documentElement.classList.add("wait-for-optimize");let t=0;const o=window.setInterval(()=>{(window.ga&&window.ga.loaded||t>=e)&&(document.documentElement.classList.remove("wait-for-optimize"),window.clearInterval(o)),t+=r},r)},y=()=>{if("undefined"!=typeof window){const e={};"localStorage"in window?"sessionStorage"in window&&o.storagePreference===t.sessionStorage?e.storage=window.sessionStorage:e.storage=window.localStorage:"sessionStorage"in window&&(e.storage=window.sessionStorage),"location"in window&&"search"in window.location&&(e.location=window.location),Object.keys(e).length&&p(e)}};var m=(y(),{autopersist:n,configure:p,currentExperimentId:g,discover:y,fields:s,fromQuery:f,get:u,key:i,location:a,persist:d,preventFlicker:w,storage:c,storagePreference:l,storagePreferences:t});exports.autopersist=n,exports.configure=p,exports.currentExperimentId=g,exports.default=m,exports.discover=y,exports.fields=s,exports.fromQuery=f,exports.get=u,exports.key=i,exports.location=a,exports.persist=d,exports.preventFlicker=w,exports.storage=c,exports.storagePreference=l,exports.storagePreferences=t;
//# sourceMappingURL=google-optimize-service.cjs.js.map

@@ -0,2 +1,3 @@

// https://github.com/haensl/google-optimize-service#readme v1.1.4 Copyright 2020 HP Dietz
function e(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function t(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function o(e,o,i,s){return o=o||"&",i=i||"=",null===e&&(e=void 0),"object"==typeof e?n(a(e),(function(a){var s=encodeURIComponent(t(a))+i;return r(e[a])?n(e[a],(function(e){return s+encodeURIComponent(t(e))})).join(o):s+encodeURIComponent(t(e[a]))})).join(o):s?encodeURIComponent(t(s))+i+encodeURIComponent(t(e)):""}function n(e,r){if(e.map)return e.map(r);for(var t=[],o=0;o<e.length;o++)t.push(r(e[o],o));return t}var a=Object.keys||function(e){var r=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push(t);return r};function i(t,o,n,a){o=o||"&",n=n||"=";var i={};if("string"!=typeof t||0===t.length)return i;var s=/\+/g;t=t.split(o);var c=1e3;a&&"number"==typeof a.maxKeys&&(c=a.maxKeys);var l=t.length;c>0&&l>c&&(l=c);for(var p=0;p<l;++p){var f,d,u,g,w=t[p].replace(s,"%20"),y=w.indexOf(n);y>=0?(f=w.substr(0,y),d=w.substr(y+1)):(f=w,d=""),u=decodeURIComponent(f),g=decodeURIComponent(d),e(i,u)?r(i[u])?i[u].push(g):i[u]=[i[u],g]:i[u]=g}return i}var s={encode:o,stringify:o,decode:i,parse:i},c={localStorage:"local",sessionStorage:"session"},l={autopersist:!0,fields:["variant"],key:"optimize",location:{search:""},storage:null,storagePreference:c.localStorage},p=e=>{if(Array.isArray(e)&&e.reduce((e,r)=>e&&"string"==typeof r,!0))l.fields=e.slice();else if(e)throw new TypeError("Invalid parameter. Expected newFields to be Array of strings.");return l.fields.slice()},f=e=>{if("boolean"==typeof e)l.autopersist=e;else if(void 0!==e)throw new TypeError("Invalid parameter. Expected shouldAutopersist to be boolean.");return l.autopersist},d=e=>{if("string"==typeof e)l.key=e;else if(e)throw new TypeError("Invalid parameter. Expected newKey to be string");return l.key},u=e=>{if(e){if(!("search"in e)||"string"!=typeof e.search)throw new TypeError('Invalid parameter. Expected newLocation to be object with string property "serach".');l.location=e}return{search:l.location.search}},g=e=>{if(e){if("object"!=typeof e)throw new TypeError("Invalid parameter. Expected storage to be object.");["getItem","setItem"].forEach(r=>{if("function"!=typeof e[r])throw new TypeError("Invalid parameter. Expected storage to implement function ".concat(r,"."))}),l.storage=e}return Object.assign({},l.storage)},w=e=>{if(e){if(!Object.values(c).includes(e))throw new TypeError("Invalid parameter. Expected newStoragePreference to be on of ".concat(Object.values(c).join(", "),"."));l.storagePreference=e}return l.storagePreference},y=e=>{if("object"!=typeof e)throw new TypeError("Invalid parameter. Expected opts to be object.");Object.keys(l).forEach(r=>{if(r in e)try{switch(r){case"autopersist":f(e.autopersist);break;case"key":d(e.key);break;case"location":u(e.location);break;case"storage":g(e.storage);break;case"storagePreference":w(e.storagePreference);break;case"fields":p(e.fields)}}catch(e){throw new TypeError("Invalid option: ".concat(r,"."),e.message)}})},m=()=>{var e={};if(l.location){var r=s.parse(l.location.search.replace(/^\?/,""));"utm_expid"in r&&(e.experimentId=r.utm_expid),"utm_referrer"in r&&(e.referrer=r.utm_referrer),(l.fields||[]).forEach(t=>{t in r&&(e[t]=r[t])})}return Object.keys(e).length?e:null},v=()=>{if(l.storage){var e=l.storage.getItem(l.key);if(e)return JSON.parse(e)}return null},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:I();l.storage&&l.storage.setItem(l.key,JSON.stringify(e))},b=()=>{if(l.location){var e=m();if(e)return e.experimentId}},I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b(),r=v(),t=m(),o=r||{};return t&&!(t.experimentId in o)&&(o[t.experimentId]=t),l.autopersist&&h(o),e?e in o?o[e]:null:Object.keys(o).length?o:null},E=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;document.documentElement.classList.add("wait-for-optimize");var t=0,o=window.setInterval(()=>{(window.ga&&window.ga.loaded||t>=e)&&(document.documentElement.classList.remove("wait-for-optimize"),window.clearInterval(o)),t+=r},r)},j=()=>{if("undefined"!=typeof window){var e={};"localStorage"in window?"sessionStorage"in window&&l.storagePreference===c.sessionStorage?e.storage=window.sessionStorage:e.storage=window.localStorage:"sessionStorage"in window&&(e.storage=window.sessionStorage),"location"in window&&"search"in window.location&&(e.location=window.location),Object.keys(e).length&&y(e)}},x=(j(),{autopersist:f,configure:y,currentExperimentId:b,discover:j,fields:p,fromQuery:m,get:I,key:d,location:u,persist:h,preventFlicker:E,storage:g,storagePreference:w,storagePreferences:c});export default x;export{f as autopersist,y as configure,b as currentExperimentId,j as discover,p as fields,m as fromQuery,I as get,d as key,u as location,h as persist,E as preventFlicker,g as storage,w as storagePreference,c as storagePreferences};
//# sourceMappingURL=google-optimize-service.esm.js.map

@@ -0,1 +1,2 @@

// https://github.com/haensl/google-optimize-service#readme v1.1.4 Copyright 2020 HP Dietz
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["google-optimize-service"]={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function n(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function i(e,t,r,i){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?a(s(e),(function(i){var s=encodeURIComponent(n(i))+r;return o(e[i])?a(e[i],(function(e){return s+encodeURIComponent(n(e))})).join(t):s+encodeURIComponent(n(e[i]))})).join(t):i?encodeURIComponent(n(i))+r+encodeURIComponent(n(e)):""}function a(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o<e.length;o++)r.push(t(e[o],o));return r}var s=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t};function c(e,t,n,i){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var f=e.length;c>0&&f>c&&(f=c);for(var u=0;u<f;++u){var l,p,d,g,y=e[u].replace(s,"%20"),m=y.indexOf(n);m>=0?(l=y.substr(0,m),p=y.substr(m+1)):(l=y,p=""),d=decodeURIComponent(l),g=decodeURIComponent(p),r(a,d)?o(a[d])?a[d].push(g):a[d]=[a[d],g]:a[d]=g}return a}var f={encode:i,stringify:i,decode:c,parse:c},u={localStorage:"local",sessionStorage:"session"},l={autopersist:!0,fields:["variant"],key:"optimize",location:{search:""},storage:null,storagePreference:u.localStorage},p=function(e){if(Array.isArray(e)&&e.reduce((function(e,t){return e&&"string"==typeof t}),!0))l.fields=e.slice();else if(e)throw new TypeError("Invalid parameter. Expected newFields to be Array of strings.");return l.fields.slice()},d=function(e){if("boolean"==typeof e)l.autopersist=e;else if(void 0!==e)throw new TypeError("Invalid parameter. Expected shouldAutopersist to be boolean.");return l.autopersist},g=function(e){if("string"==typeof e)l.key=e;else if(e)throw new TypeError("Invalid parameter. Expected newKey to be string");return l.key},y=function(e){if(e){if(!("search"in e)||"string"!=typeof e.search)throw new TypeError('Invalid parameter. Expected newLocation to be object with string property "serach".');l.location=e}return{search:l.location.search}},m=function(e){if(e){if("object"!==t(e))throw new TypeError("Invalid parameter. Expected storage to be object.");["getItem","setItem"].forEach((function(t){if("function"!=typeof e[t])throw new TypeError("Invalid parameter. Expected storage to implement function ".concat(t,"."))})),l.storage=e}return Object.assign({},l.storage)},w=function(e){if(e){if(!Object.values(u).includes(e))throw new TypeError("Invalid parameter. Expected newStoragePreference to be on of ".concat(Object.values(u).join(", "),"."));l.storagePreference=e}return l.storagePreference},v=function(e){if("object"!==t(e))throw new TypeError("Invalid parameter. Expected opts to be object.");Object.keys(l).forEach((function(t){if(t in e)try{switch(t){case"autopersist":d(e.autopersist);break;case"key":g(e.key);break;case"location":y(e.location);break;case"storage":m(e.storage);break;case"storagePreference":w(e.storagePreference);break;case"fields":p(e.fields)}}catch(e){throw new TypeError("Invalid option: ".concat(t,"."),e.message)}}))},b=function(){var e={};if(l.location){var t=f.parse(l.location.search.replace(/^\?/,""));"utm_expid"in t&&(e.experimentId=t.utm_expid),"utm_referrer"in t&&(e.referrer=t.utm_referrer),(l.fields||[]).forEach((function(r){r in t&&(e[r]=t[r])}))}return Object.keys(e).length?e:null},h=function(){if(l.storage){var e=l.storage.getItem(l.key);if(e)return JSON.parse(e)}return null},I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:j();l.storage&&l.storage.setItem(l.key,JSON.stringify(e))},E=function(){if(l.location){var e=b();if(e)return e.experimentId}},j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:E(),t=h(),r=b(),o=t||{};return r&&!(r.experimentId in o)&&(o[r.experimentId]=r),l.autopersist&&I(o),e?e in o?o[e]:null:Object.keys(o).length?o:null},x=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;document.documentElement.classList.add("wait-for-optimize");var r=0,o=window.setInterval((function(){(window.ga&&window.ga.loaded||r>=e)&&(document.documentElement.classList.remove("wait-for-optimize"),window.clearInterval(o)),r+=t}),t)},k=function(){if("undefined"!=typeof window){var e={};"localStorage"in window?"sessionStorage"in window&&l.storagePreference===u.sessionStorage?e.storage=window.sessionStorage:e.storage=window.localStorage:"sessionStorage"in window&&(e.storage=window.sessionStorage),"location"in window&&"search"in window.location&&(e.location=window.location),Object.keys(e).length&&v(e)}},S=(k(),{autopersist:d,configure:v,currentExperimentId:E,discover:k,fields:p,fromQuery:b,get:j,key:g,location:y,persist:I,preventFlicker:x,storage:m,storagePreference:w,storagePreferences:u});e.autopersist=d,e.configure=v,e.currentExperimentId=E,e.default=S,e.discover=k,e.fields=p,e.fromQuery=b,e.get=j,e.key=g,e.location=y,e.persist=I,e.preventFlicker=x,e.storage=m,e.storagePreference=w,e.storagePreferences=u}));

30

package.json
{
"name": "google-optimize-service",
"version": "1.1.3",
"version": "1.1.4",
"description": "Highly customizable, dependency-free, universal, service abstraction around Google Optimize.",

@@ -10,3 +10,4 @@ "main": "lib/google-optimize-service.cjs.js",

"scripts": {
"build": "rollup -c",
"build": "npm run clean && rollup -c",
"clean": "rimraf ./dist",
"test": "jest --testPathIgnorePatterns=/package-tests/ --env=jsdom",

@@ -55,23 +56,24 @@ "test:ci": "jest --runInBand --no-cache --ci --reporters='default' --testPathIgnorePatterns=/package-tests/ --reporters='jest-junit' --passWithNoTests",

"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@haensl/eslint-config": "^1.3.0",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"babel-jest": "^26.3.0",
"eslint": "^7.8.1",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.13.0",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest-junit": "^11.1.0",
"rollup": "^2.26.11",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.33.2",
"rollup-plugin-ascii": "0.0.3",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-peer-deps-external": "^2.2.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"@babel/runtime": "^7.11.2"
"@babel/runtime": "^7.12.5"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc