• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adobe / reactor-turbine / 26974271630

04 Jun 2026 07:23PM UTC coverage: 18.928% (-77.0%) from 95.912%
26974271630

Pull #201

github

web-flow
Merge 99f374fa8 into 4a42733a4
Pull Request #201: Platir 64071 update vulnerability chain

36 of 379 branches covered (9.5%)

Branch coverage included in aggregate %.

4 of 6 new or added lines in 1 file covered. (66.67%)

640 existing lines in 47 files now uncovered.

197 of 852 relevant lines covered (23.12%)

1.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.74
/src/dataElementSafe.js
1
/***************************************************************************************
2
 * (c) 2017 Adobe. All rights reserved.
3
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License. You may obtain a copy
5
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
 *
7
 * Unless required by applicable law or agreed to in writing, software distributed under
8
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
 * OF ANY KIND, either express or implied. See the License for the specific language
10
 * governing permissions and limitations under the License.
11
 ****************************************************************************************/
12

13
var getNamespacedStorage = require('./getNamespacedStorage');
3✔
14

15
var DATA_ELEMENTS_NAMESPACE = 'dataElements.';
3✔
16

17
var dataElementSessionStorage = getNamespacedStorage(
3✔
18
  'sessionStorage',
19
  DATA_ELEMENTS_NAMESPACE
20
);
21
var dataElementLocalStorage = getNamespacedStorage(
3✔
22
  'localStorage',
23
  DATA_ELEMENTS_NAMESPACE
24
);
25

26
var storageDurations = {
3✔
27
  PAGEVIEW: 'pageview',
28
  SESSION: 'session',
29
  VISITOR: 'visitor'
30
};
31

32
var pageviewCache = {};
3✔
33

34
var serialize = function (value) {
3✔
35
  var serialized;
36

UNCOV
37
  try {
×
38
    // On some browsers, with some objects, errors will be thrown during serialization. For example,
39
    // in Chrome with the window object, it will throw "TypeError: Converting circular structure
40
    // to JSON"
UNCOV
41
    serialized = JSON.stringify(value);
×
42
    // eslint-disable-next-line no-empty, no-unused-vars
43
  } catch (e) {}
44

UNCOV
45
  return serialized;
×
46
};
47

48
var setValue = function (key, storageDuration, value) {
3✔
49
  var serializedValue;
50

UNCOV
51
  switch (storageDuration) {
×
52
    case storageDurations.PAGEVIEW:
UNCOV
53
      pageviewCache[key] = value;
×
UNCOV
54
      return;
×
55
    case storageDurations.SESSION:
UNCOV
56
      serializedValue = serialize(value);
×
UNCOV
57
      if (serializedValue) {
×
UNCOV
58
        dataElementSessionStorage.setItem(key, serializedValue);
×
59
      }
UNCOV
60
      return;
×
61
    case storageDurations.VISITOR:
UNCOV
62
      serializedValue = serialize(value);
×
UNCOV
63
      if (serializedValue) {
×
UNCOV
64
        dataElementLocalStorage.setItem(key, serializedValue);
×
65
      }
UNCOV
66
      return;
×
67
  }
68
};
69

70
var getValue = function (key, storageDuration) {
3✔
71
  var value;
72

73
  // It should consistently return the same value if no stored item was found. We chose null,
74
  // though undefined could be a reasonable value as well.
UNCOV
75
  switch (storageDuration) {
×
76
    case storageDurations.PAGEVIEW:
UNCOV
77
      return pageviewCache.hasOwnProperty(key) ? pageviewCache[key] : null;
×
78
    case storageDurations.SESSION:
UNCOV
79
      value = dataElementSessionStorage.getItem(key);
×
UNCOV
80
      return value === null ? value : JSON.parse(value);
×
81
    case storageDurations.VISITOR:
UNCOV
82
      value = dataElementLocalStorage.getItem(key);
×
UNCOV
83
      return value === null ? value : JSON.parse(value);
×
84
  }
85
};
86

87
module.exports = {
3✔
88
  setValue: setValue,
89
  getValue: getValue
90
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc