Sha256: f86811be2b26ab0f777764053b57235c4f5145b08c6881b3319251d58779cd95

Contents?: true

Size: 1.89 KB

Versions: 52

Compression:

Stored size: 1.89 KB

Contents

// Map Functions
// =============


// Truncate List
// -------------
// - Return a list, truncated to a given length
@function _susy-truncate-list(
  $list,
  $length
) {
  $_return: ();

  @for $i from 1 through length($list) {
    $_return: if($i <= $length, append($_return, nth($list, $i)), $_return);
  }

  @return $_return;
}


// Deep Get
// --------
// - Return a value deep in nested maps
@function _susy-deep-get(
  $map,
  $keys...
) {
  $_return: $map;

  @each $key in $keys {
    @if type-of($_return) == map {
      $_return: map-get($_return, $key);
    }
  }

  @return $_return;
}


// Deep Set
// --------
// - Set a value deep in nested maps
@function _susy-deep-set(
  $map,
  $keys-value...
) {
  $_value: nth($keys-value, -1);
  $_keys: _susy-truncate-list($keys-value, length($keys-value) - 1);
  $_length: length($_keys);
  $_return: ();

  @for $i from 1 through $_length {
    $_n: 0 - $i;
    $_level: _susy-truncate-list($_keys, $_length + $_n);
    $_level: _susy-deep-get($map, $_level...);
    $_merge: (nth($_keys, $_n): $_value);
    $_return: if($_level, map-merge($_level, $_merge), $_merge);
    $_value: $_return;
  }

  @return $_return;
}


// Deep Merge
// ----------
// Return 2 objects of any depth, merged
@function _susy-deep-merge(
  $map1,
  $map2
) {

  @if type-of($map1) != map or type-of($map2) != map {
    $map1: $map2;
  } @else {
    @each $key, $value in $map2 {
      $_new: ($key: _susy_deep-merge(map-get($map1, $key), $value));
      $map1: map-merge($map1, $_new);
    }
  }

  @return $map1;
}


// Deep Has-Key
// ------------
// - Return true if a deep key exists
@function _susy-deep-has-key(
  $map,
  $keys...
) {
  $_return: null;
  $_stop: false;

  @each $key in $keys {
    @if not $_stop {
      $_return: map-has-key($map, $key);
    }

    @if $_return {
      $map: map-get($map, $key);
    } @else {
      $_stop: true;
    }
  }

  @return $_return;
}

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
wrgem-0.0.55 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.54 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.53 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.52 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.51 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.50 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.49 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.48 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.47 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.46 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.45 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.44 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.43 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.42 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.41 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.40 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.39 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.38 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.37 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss
wrgem-0.0.35 lib/generators/wrstart/template/vendor/assets/components/susy/sass/susy/math/su/_maps.scss