@kizmann/pico-js 0.3.32 → 0.3.34
Sign up to get free protection for your applications and to get access to all the features.
- 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/object.js +30 -2
- package/src/utility/string.js +5 -5
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/object.js
CHANGED
@@ -3,9 +3,37 @@ import Any from "./any";
|
|
3
3
|
|
4
4
|
export class Obj
|
5
5
|
{
|
6
|
-
static has(obj,
|
6
|
+
static has(obj, keys)
|
7
7
|
{
|
8
|
-
|
8
|
+
if ( obj === null || obj === undefined ) {
|
9
|
+
return false;
|
10
|
+
}
|
11
|
+
|
12
|
+
if ( keys === null || keys === undefined ) {
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
|
16
|
+
if ( Any.isArray(keys) ) {
|
17
|
+
keys = keys.join('.');
|
18
|
+
}
|
19
|
+
|
20
|
+
if ( ! Any.isString(keys) ) {
|
21
|
+
keys = keys.toString();
|
22
|
+
}
|
23
|
+
|
24
|
+
keys = keys.split('.');
|
25
|
+
|
26
|
+
let lst = keys.pop(), index = 0, length = keys.length;
|
27
|
+
|
28
|
+
while (obj !== undefined && obj !== null && index < length) {
|
29
|
+
obj = obj[keys[index++]];
|
30
|
+
}
|
31
|
+
|
32
|
+
if ( obj === undefined || obj === null) {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
|
36
|
+
return obj[lst] !== undefined;
|
9
37
|
}
|
10
38
|
|
11
39
|
static empty(obj, key)
|
package/src/utility/string.js
CHANGED
@@ -107,16 +107,16 @@ 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
|
|