Skip to content

Instantly share code, notes, and snippets.

@kmod-midori
Created February 13, 2013 14:48
Show Gist options
  • Save kmod-midori/4945075 to your computer and use it in GitHub Desktop.
Save kmod-midori/4945075 to your computer and use it in GitHub Desktop.
var sm=function(s){
if(typeof s !='object'||s==null)var s=[];
if(typeof s.length =='undefined')s=[s];
return {
segments:s,
addText:function(text){
this.segments.push({
text:text,
type:'TEXT'
});
},
addMention:function(name,id){
this.segments.push({
text:'+'+name,
type:'USER_MENTION',
user:{
name:name,
userId:id
}
});
},
pop:function(time){
if(typeof time =='undefined')var time=1
if(isNaN(parseInt(time)))time=1;
var i=0;
while(i<time){
this.segments.pop();
i++;
}
}
};
};
module.exports=sm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment