// =============================================================================
// =ALEKSI - MAP-HAS-KEYS
// =============================================================================
////
//// @group aleksi-maps
//// @author [Yoannis Jamar](https://yoannis.com)

@import "aleksi/general/throw";
@import "aleksi/maps/is-map";

// =map-has-keys( $map, $keys )
// -----------------------------------------------------------------------------
/// Tests if a map has all the given keys at first level.
/// @author [Hugo Giraudel](http://hugogiraudel.com)
///
/// @param {map} $map - The map to search in for `$keys...`.
/// @param {list} $keys - The keys to search for.
///
/// @return {bool} - Whether all keys were found in first level of `$map`.
/// @throw Error if `$map` is not a map.
///
/// @example scss
///   $foo: map-has-keys( ('a': 'foo', 'b': 'bar', 'c': 'baz'), 'a', 'd');
///     // => false
///   $bar: map-has-keys( ('a': 'foo', 'b': 'bar', 'c': 'baz'), 'a', 'b');
///     // => true
///
/// @access public
/// @since 0.1.0

@function map-has-keys($map, $keys)
{
  @if not is-map($map) {
    @return throw-error('map-has-keys():: $map must be a map, was #{inspect($map)}.');
  }

  @each $key in $keys {
    @if not map-has-key($map, $key) {
      @return false;
    }
  }

  @return true;
}
