Skip to content

finagin/Slavunya.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slavunya.js

Install

Add script //cdn.rawgit.com/finagin/Slavunya.js/v1.1.2/dist/Slavunya.min.js to your code

<body>
    <div class="content">...</div>

    <script src="//cdn.rawgit.com/finagin/Slavunya.js/v1.1.2/dist/Slavunya.min.js"></script>
    <script src="/main.min.js"></script>
</body>

Usage

Slavunya.cookies(name, [value, [days, [secure]]])

> Slavunya.cookies("page")
< 2

> Slavunya.cookies("page", 3, 7)
< undefined
> Slavunya.cookies("page")
< 3

Slavunya.math(number)

Slavunya.math(number).in(...numbers)

> Slavunya.math(2).in(1,2,3)
< true

> Slavunya.math(4).in(1,2,3)
< false

> Slavunya.math(2).in([1, 2, 3])
< true

Slavunya.math(number).between(left, right)

> Slavunya.math(5).between(1, 10)
< true

> Slavunya.math(15).between(1, 10)
< false

Slavunya.math(number).right(a)

> Slavunya.math(12345).right(1);
< 5

> Slavunya.math(12345).right(2);
< 45

Slavunya.math(number).declination(words)

> Slavunya.math(3).declination(["день", "дня", "дней"])
< "дня"

> Slavunya.math(11).declination(["неделя", "недели", "недель"])
< "дней"

> Slavunya.math(21).declination(["месяц", "месяца", "месяцев"])
< "месяцев"

Slavunya.urlParams([name])

/index.html?page=2&guest#block=about

> Slavunya.urlParams("page");
< 2

> Slavunya.urlParams("block");
< "about"

> Slavunya.urlParams();
< {
      page: 2,
      guest: true,
      block: "about"
  }

Slavunya.defaults(obj, def)

> Slavunya.defaults({
      name:"Igor",
      age: 22,
      city: "Kazan"
  }, {
      country: "Russia",
      city: "Moscow"
  })
< {
      name:"Igor",
      age: 22,
      country: "Russia",
      city: "Kazan"
  }

Slavunya.getRGB(color)

> Slavunya.getRGB("#E6AC0C")
< [230, 172, 12]

Slavunya.toCamelCase(str, [strict])

> Slavunya.toCamelCase("to-camel-case")
< toCamelCase

> Slavunya.toCamelCase("TO-CAMEL-CASE", true)
< toCamelCase