@kizmann/pico-js 0.3.35 → 0.3.37

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/pico-js",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -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
  }
@@ -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;