Pārlūkot izejas kodu

added npmignore and use files property in package.json instead;
added array flatten method;
added 'use strict' statements in each library file;

mightyplow 8 gadi atpakaļ
vecāks
revīzija
59f26199ba
9 mainītis faili ar 31 papildinājumiem un 4 dzēšanām
  1. 0 3
      .npmignore
  2. 3 0
      jslib.js
  3. 13 0
      lib/array.js
  4. 2 0
      lib/file.js
  5. 2 0
      lib/html.js
  6. 2 0
      lib/object.js
  7. 2 0
      lib/string.js
  8. 2 0
      lib/stylesheet.js
  9. 5 1
      package.json

+ 0 - 3
.npmignore

@@ -1,3 +0,0 @@
-.jshintrc
-/.idea/
-.npmignore

+ 3 - 0
jslib.js

@@ -1,4 +1,7 @@
+'use strict'
+
 module.exports = {
+    array: require('./lib/array'),
     file: require('./lib/file'),
     html: require('./lib/html'),
     object: require('./lib/object'),

+ 13 - 0
lib/array.js

@@ -0,0 +1,13 @@
+'use strict'
+
+module.exports = {
+    flatten: ar => ar.reduce((acc, item) => {
+        if (Array.isArray(item)) {
+            acc.push.apply(acc, flatten(item))
+        } else {
+            acc.push(item)
+        }
+
+        return acc
+    }, [])
+}

+ 2 - 0
lib/file.js

@@ -1,3 +1,5 @@
+'use strict'
+
 const fs = require('fs')
 
 module.exports = {

+ 2 - 0
lib/html.js

@@ -1,3 +1,5 @@
+'use strict'
+
 module.exports = {
     createLinkTag: (filename, selector) => {
         if (selector) {

+ 2 - 0
lib/object.js

@@ -1,3 +1,5 @@
+'use strict'
+
 module.exports = {
     prop: prop => obj => obj[prop],
 

+ 2 - 0
lib/string.js

@@ -1,3 +1,5 @@
+'use strict'
+
 module.exports = {
     append: (str, append) => str + append,
     toBool: val => val === 'true'

+ 2 - 0
lib/stylesheet.js

@@ -1,3 +1,5 @@
+'use strict'
+
 module.exports = {
     getRules: css => css.stylesheet.rules,
     isRuleType: type => rule => rule.type === type,

+ 5 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@mightyplow/jslib",
-  "version": "0.1.2",
+  "version": "0.1.3",
   "description": "js helpers library",
   "main": "jslib.js",
   "dependencies": {
@@ -9,6 +9,10 @@
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
+  "files": [
+    "lib",
+    "jslib.js"
+  ],
   "keywords": ["js", "javascript", "helpers", "library"],
   "author": {
     "name": "mightyplow",