PageSourceSearch

https://extragreat.ai/lib/js.cookie.mjs

js extragreat.ai collected 2026-10-05 16:18:56 UTC 3,475 bytes, 134 lines download raw bytes

vendor: 1,440 bytes, lines 1-57
1/*! js-cookie v3.0.5 | MIT */
2/* eslint-disable no-var */
3function assign (target) {
4  for (var i = 1; i < arguments.length; i++) {
5    var source = arguments[i];
6    for (var key in source) {
7      target[key] = source[key];
8    }
9  }
10  return target
11}
12/* eslint-enable no-var */
13
14/* eslint-disable no-var */
15var defaultConverter = {
16  read: function (value) {
17    if (value[0] === '"') {
18      value = value.slice(1, -1);
19    }
20    return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
21  },
22  write: function (value) {
23    return encodeURIComponent(value).replace(
24      /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
25      decodeURIComponent
26    )
27  }
28};
29/* eslint-enable no-var */
30
31/* eslint-disable no-var */
32
33function init (converter, defaultAttributes) {
34  function set (name, value, attributes) {
35    if (typeof document === 'undefined') {
36      return
37    }
38
39    attributes = assign({}, defaultAttributes, attributes);
40
41    if (typeof attributes.expires === 'number') {
42      attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
43    }
44    if (attributes.expires) {
45      attributes.expires = attributes.expires.toUTCString();
46    }
47
48    name = encodeURIComponent(name)
49      .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
50      .replace(/[()]/g, escape);
51
52    var stringifiedAttributes = '';
53    for (var attributeName in attributes) {
54      if (!attributes[attributeName]) {
55        continue
56      }
57
vendor: 2,035 bytes, lines 58-134
58      stringifiedAttributes += '; ' + attributeName;
59
60      if (attributes[attributeName] === true) {
61        continue
62      }
63
64      // Considers RFC 6265 section 5.2:
65      // ...
66      // 3.  If the remaining unparsed-attributes contains a %x3B (";")
67      //     character:
68      // Consume the characters of the unparsed-attributes up to,
69      // not including, the first %x3B (";") character.
70      // ...
71      stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
72    }
73
74    return (document.cookie =
75      name + '=' + converter.write(value, name) + stringifiedAttributes)
76  }
77
78  function get (name) {
79    if (typeof document === 'undefined' || (arguments.length && !name)) {
80      return
81    }
82
83    // To prevent the for loop in the first place assign an empty array
84    // in case there are no cookies at all.
85    var cookies = document.cookie ? document.cookie.split('; ') : [];
86    var jar = {};
87    for (var i = 0; i < cookies.length; i++) {
88      var parts = cookies[i].split('=');
89      var value = parts.slice(1).join('=');
90
91      try {
92        var found = decodeURIComponent(parts[0]);
93        jar[found] = converter.read(value, found);
94
95        if (name === found) {
96          break
97        }
98      } catch (e) {}
99    }
100
101    return name ? jar[name] : jar
102  }
103
104  return Object.create(
105    {
106      set,
107      get,
108      remove: function (name, attributes) {
109        set(
110          name,
111          '',
112          assign({}, attributes, {
113            expires: -1
114          })
115        );
116      },
117      withAttributes: function (attributes) {
118        return init(this.converter, assign({}, this.attributes, attributes))
119      },
120      withConverter: function (converter) {
121        return init(assign({}, this.converter, converter), this.attributes)
122      }
123    },
124    {
125      attributes: { value: Object.freeze(defaultAttributes) },
126      converter: { value: Object.freeze(converter) }
127    }
128  )
129}
130
131var api = init(defaultConverter, { path: '/' });
132/* eslint-enable no-var */
133
134export { api as default };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.