Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Created November 16, 2013 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiebuilds/7503170 to your computer and use it in GitHub Desktop.
Save jamiebuilds/7503170 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
$store: ();
@function store-get($key) {
@each $item in $store {
@if nth($item, 1) == $key {
@return nth($item, 2);
}
}
@return null;
}
@function store-index($key) {
$index: false;
@for $i from 1 through length($store) {
@if nth(nth($store, $i), 1) == $key {
$index: $i;
}
}
@return $index;
}
@function store-set($key, $value) {
$index: store-index($key);
@if $index {
$result: ();
@for $i from 1 through length($store) {
@if $i == $index {
$result: append($result, ( $key $value ), comma);
} @else {
$result: append($result, nth($store, $i), comma);
}
}
$store: $result;
} @else {
$store: append( $store, ($key $value), comma );
}
@return true;
}
TEST {
before: store-get(test);
create: store-set(test, create);
after: store-get(test);
update: store-set(test, update);
final: store-get(test);
store: $store;
}
TEST {
create: true;
after: create;
update: true;
final: update;
store: test update;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment