@kizmann/pico-js 0.3.35 → 0.3.37
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 +7 -0
- package/package.json +1 -1
- package/src/library/map.js +5 -0
- package/src/utility/object.js +28 -0
package/docs/cookie.html
CHANGED
@@ -29,6 +29,13 @@
|
|
29
29
|
'use strict';
|
30
30
|
|
31
31
|
pi.Dom.ready(function() {
|
32
|
+
|
33
|
+
var obj = {
|
34
|
+
foo: { bar: 'key' }, hu: 'tem', ka: { se: { nope: 'lol' } }
|
35
|
+
};
|
36
|
+
|
37
|
+
console.log(pi.Obj.flatten(obj));
|
38
|
+
|
32
39
|
console.log(pi.Str.real('@[\'\']'));
|
33
40
|
console.log(pi.Str.real('@[1,"foo",3]'));
|
34
41
|
pi.Cookie.set('foobar1', { foo: 'bar', pi: { nano: 'ui', kyoto: 'cms' } });
|
package/package.json
CHANGED
package/src/library/map.js
CHANGED
@@ -29,6 +29,7 @@ export default class Map
|
|
29
29
|
if ( ! global.google ) {
|
30
30
|
return console.error('Google Maps is not loaded.');
|
31
31
|
}
|
32
|
+
|
32
33
|
let center = Obj.only(options, ['lat', 'lng']);
|
33
34
|
|
34
35
|
if ( ! Obj.has(options, 'styles') ) {
|
@@ -50,6 +51,10 @@ export default class Map
|
|
50
51
|
|
51
52
|
static setMarkerStyle(key, style = {}, extra = {})
|
52
53
|
{
|
54
|
+
if ( ! global.google ) {
|
55
|
+
return console.error('Google Maps is not loaded.');
|
56
|
+
}
|
57
|
+
|
53
58
|
if ( ! Obj.has(style, 'default') ) {
|
54
59
|
return console.error('Marker style requires default property')
|
55
60
|
}
|
package/src/utility/object.js
CHANGED
@@ -379,6 +379,34 @@ export class Obj
|
|
379
379
|
return result;
|
380
380
|
}
|
381
381
|
|
382
|
+
static flatten(obj)
|
383
|
+
{
|
384
|
+
let result = {};
|
385
|
+
|
386
|
+
let callback = (val, sey = null) => {
|
387
|
+
|
388
|
+
Arr.each(Any.keys(val), (key) => {
|
389
|
+
|
390
|
+
let tey = key;
|
391
|
+
|
392
|
+
if ( ! Any.isEmpty(sey) ) {
|
393
|
+
tey = `${sey}.${key}`;
|
394
|
+
}
|
395
|
+
|
396
|
+
if ( Any.isPlain(val[key]) ) {
|
397
|
+
return callback(val[key], tey);
|
398
|
+
}
|
399
|
+
|
400
|
+
result[tey] = val[key];
|
401
|
+
});
|
402
|
+
|
403
|
+
};
|
404
|
+
|
405
|
+
callback(obj);
|
406
|
+
|
407
|
+
return result;
|
408
|
+
}
|
409
|
+
|
382
410
|
}
|
383
411
|
|
384
412
|
export default Obj;
|