Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created September 26, 2011 19:21
Show Gist options
  • Save natecavanaugh/1243123 to your computer and use it in GitHub Desktop.
Save natecavanaugh/1243123 to your computer and use it in GitHub Desktop.
Prefix suffix generation
var BUFFER_PREF_SUFF = [];
A.mix(
LString,
{
prefixFn: A.cached(
function(prefix) {
var instance = this;
return A.rbind('suffix', LString, prefix);
}
),
suffixFn: A.cached(
function(suffix) {
var instance = this;
return A.bind('suffix', LString, suffix);
}
),
prefix: A.cached(
function(prefix, str) {
var instance = this;
BUFFER_PREF_SUFF[0] = prefix;
BUFFER_PREF_SUFF[1] = str;
return BUFFER_PREF_SUFF.join('');
}
),
suffix: A.cached(
function(suffix, str) {
var instance = this;
BUFFER_PREF_SUFF[0] = str;
BUFFER_PREF_SUFF[1] = suffix;
return BUFFER_PREF_SUFF.join('');
}
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment