Giter Site home page Giter Site logo

generaljs's Introduction

GeneralJS Build Status

A general purpose JavaScript library.

Strings

format

"This is pretty {0}".format("cool");

log

var user = "John Doe";
user.log();
user.log("Current User");
=> John Doe
=> Current User: John Doe

toInt(fallback)

"123".toInt();
"123a".toInt(3);

reverse

"test".reverse();

Output:

tset

Boolean

flip

var test = true;
test.flip();

Helpful when making a toggle function:

<button ng-click="displayStuff.flip()"></button>

log

var active = true;
active.log();
active.log("Active");
=> true
=> Active : true

Array

last

The last function will return the last item in the array.

var arr = [ 'one', 'two', 'three' ];
arr.last();
=> 'three'

log

var arr = [ 'one', 'two', 'three' ];
arr.log();
arr.log("Message");
=> [ 'one', 'two', 'three' ]
=> Message: [ 'one', 'two', 'three' ]

asArray

This function will return the passed object as an array. Useful when objects or arrays can be supplied.

var a = 1;
var b = [1,2,3];
Array.asArray(a);
Array.asArray(b);
=> [1];
=> [1,2,3];

Object

getValue

This function will test if an object has a property and return it. It can also take in compound properties (i.e. find property recursively). Will return fallBack value if no matches are made and false if no matches and no fallBack.

var obj = {'a': { 'b' : { 123 } }, 'b' : 2, 'c' : 3};
obj.getValue("c");
=> 3;    
obj.getValue("d",4);
=> 4;
obj.getValue("a.b");
=> 123;

generaljs's People

Contributors

martinjay180 avatar waffle-iron avatar

Stargazers

vadxq avatar

Watchers

 avatar

generaljs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.