@kizmann/pico-js 0.3.31 → 0.3.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pico-js.js +1 -1
- package/dist/pico-js.js.map +1 -1
- package/docs/cookie.html +2 -1
- package/package.json +1 -1
- package/src/utility/string.js +7 -7
package/docs/cookie.html
CHANGED
@@ -29,7 +29,8 @@
|
|
29
29
|
'use strict';
|
30
30
|
|
31
31
|
pi.Dom.ready(function() {
|
32
|
-
console.log(pi.Str.real('[
|
32
|
+
console.log(pi.Str.real('@[\'\']'));
|
33
|
+
console.log(pi.Str.real('@[1,"foo",3]'));
|
33
34
|
pi.Cookie.set('foobar1', { foo: 'bar', pi: { nano: 'ui', kyoto: 'cms' } });
|
34
35
|
console.log(pi.Cookie.get('foobar1', {}, 'object'));
|
35
36
|
pi.Cookie.set('foobar2', ['foo', 'bar', 1], 60 * 60);
|
package/package.json
CHANGED
package/src/utility/string.js
CHANGED
@@ -107,26 +107,26 @@ export class Str
|
|
107
107
|
return size;
|
108
108
|
}
|
109
109
|
|
110
|
-
static array(value, fallback =
|
110
|
+
static array(value, fallback = [])
|
111
111
|
{
|
112
|
-
|
112
|
+
value = value.replace(/^@\[(.*?)?\]$/, '$1');
|
113
113
|
|
114
|
-
if (
|
114
|
+
if ( Any.isEmpty(value) ) {
|
115
115
|
return fallback;
|
116
116
|
}
|
117
117
|
|
118
|
-
return Arr.each(
|
119
|
-
return Str.real(
|
118
|
+
return Arr.each(value.split(','), (val) => {
|
119
|
+
return Str.real(val.replace(/(^"|^'|"$|'$)/g, ''));
|
120
120
|
});
|
121
121
|
}
|
122
122
|
|
123
123
|
static real(value)
|
124
124
|
{
|
125
|
-
if ( typeof value === 'string' && value.match(
|
125
|
+
if ( typeof value === 'string' && value.match(/^@\[.*?\]$/) ) {
|
126
126
|
value = Str.array(value);
|
127
127
|
}
|
128
128
|
|
129
|
-
if ( typeof value === 'string' && value.match(/^(null)$/i) ) {
|
129
|
+
if ( typeof value === 'string' && value.match(/^(null|undefined)$/i) ) {
|
130
130
|
value = null;
|
131
131
|
}
|
132
132
|
|