Skip to content

Commit

Permalink
feat(identity): initial commit of function
Browse files Browse the repository at this point in the history
  • Loading branch information
jackw committed Jul 4, 2020
1 parent 3406ef2 commit c9ff78c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/_identity.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import 'head';

/// A function that does nothing but return the parameter supplied to it. Good
/// as a default or placeholder function.
///
/// @group function
/// @return {bool} true
///
/// @example scss - indentity
///
/// $is-one: identity(1);
/// @debug $is-one; //=> 1

@function identity($args...) {
@return head($args);
}
10 changes: 10 additions & 0 deletions test/_identity.spec.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import 'true';
@import '../src/identity';

@include describe('identity [function]') {
@include it('returns its first argument') {
@include assert-equal(identity(null), null);
@include assert-equal(identity('foo'), 'foo');
@include assert-equal(identity('foo', 'bar'), 'foo');
}
}

0 comments on commit c9ff78c

Please sign in to comment.