Permalink
Browse files

one less dependency

One less installation warning too.
  • Loading branch information...
ForestMist committed Jan 26, 2018
1 parent 9558a1e commit 51e3f112feb3ce81a23dbaf14cf56f28592f4c92
Showing with 13 additions and 33 deletions.
  1. +1 −2 code/2 - shared.js
  2. +8 −14 code/4 - functions.js
  3. +3 −3 docs/api/shared.md
  4. +0 −12 mocha/2 - shared.js
  5. +1 −2 package.json
View
@@ -5,7 +5,6 @@
//----------
var os = require('os') // ~ 1 ms
var path = require('path') // ~ 1 ms
var uniqueNumber = require("unique-number") // ~ 2 ms
//-----------
// Functions
@@ -172,7 +171,7 @@ var shared = {
}
},
suppressWatchEvents: false, // Used to temporarily suppress watch events for command line users until the title "Watching" is displayed. Can also be used to temporarily suppress watch events without having to stop the watch process.
uniqueNumber: new uniqueNumber() // An instance of unique-number that is used to ensure unique property names in functions like functions.includePathsEjs.
uniqueNumber: 0 // iterate with (++uniqueNumber) or reset to 0
}
//------------------
View
@@ -15,7 +15,6 @@ var glob = require('glob') // ~ 13 ms
var mkdirp = require('mkdirp') // ~ 1 ms
var path = require('path') // ~ 1 ms
var promisify = require("es6-promisify") // ~ 4 ms
var uniqueNumber = require("unique-number") // ~ 2 ms
//---------------------
// Includes: Promisify
@@ -66,7 +65,7 @@ functions.cacheReset = function functions_cacheReset() {
shared.cache[i] = shared.cache[i].constructor()
}
shared.uniqueNumber = new uniqueNumber()
shared.uniqueNumber = 0
} // cacheReset
functions.changeExt = function functions_changeExt(filePath, newExtension) {
@@ -116,11 +115,6 @@ functions.cloneObj = function functions_cloneObj(object) {
return new RegExp(object)
}
// unique procedure to support cloning shared.uniqueNumber
if (object instanceof uniqueNumber) {
return new uniqueNumber()
}
var objectConstructor = object.constructor()
for (var key in object) {
@@ -1259,7 +1253,7 @@ functions.includePathsConcat = function functions_includePathsConcat(data, fileP
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'concat' + shared.uniqueNumber.generate()
includePathsCacheName = 'concat' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1400,7 +1394,7 @@ functions.includePathsEjs = function functions_includePathsEjs(data, filePath, i
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'ejs' + shared.uniqueNumber.generate()
includePathsCacheName = 'ejs' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1511,7 +1505,7 @@ functions.includePathsJade = function functions_includePathsJade(data, filePath,
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'jade' + shared.uniqueNumber.generate()
includePathsCacheName = 'jade' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1612,7 +1606,7 @@ functions.includePathsLess = function functions_includePathsLess(data, filePath,
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'less' + shared.uniqueNumber.generate()
includePathsCacheName = 'less' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1711,7 +1705,7 @@ functions.includePathsPug = function functions_includePathsPug(data, filePath, i
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'pug' + shared.uniqueNumber.generate()
includePathsCacheName = 'pug' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1813,7 +1807,7 @@ functions.includePathsSass = function functions_includePathsSass(data, filePath,
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'sass' + shared.uniqueNumber.generate()
includePathsCacheName = 'sass' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
@@ -1951,7 +1945,7 @@ functions.includePathsStylus = function functions_includePathsStylus(data, fileP
if (typeof includePathsCacheName === 'undefined') {
cleanup = true
includePathsCacheName = 'styl' + shared.uniqueNumber.generate()
includePathsCacheName = 'styl' + (++shared.uniqueNumber)
shared.cache.includeFilesSeen[includePathsCacheName] = [filePath]
}
View
@@ -221,10 +221,10 @@ shared.suppressWatchEvents = false // default
## shared.uniqueNumber
Type: `object`
Type: `number`
An instance of [unique-number](https://www.npmjs.com/package/unique-number) that is used to ensure unique property names in functions like [functions.includePathsEjs](functions.md#functionsincludepathsejs).
Iterate with `(++shared.uniqueNumber)` or reset back to 0. Used to ensure unique property names in functions like [functions.includePathsEjs](functions.md#functionsincludepathsejs).
## License
MIT © [Daniel Gagan](https://forestmist.org)
MIT © [Daniel Gagan](https://forestmist.org)
View
@@ -49,18 +49,6 @@ describe('File -> ../code/2 - shared.js\n', function() {
})
}) // it
it('uniqueNumber.generate() should return incrementing numbers', function() {
var test1 = shared.uniqueNumber.generate()
var test2 = shared.uniqueNumber.generate()
expect(test1).to.be.a('number')
expect(test2).to.be.a('number')
expect(test1).not.to.be(test2)
}) // it
}) // describe
}) // describe
View
@@ -41,8 +41,7 @@
"source-map": "0.7.0",
"stylus": "0.54.5",
"tiny-lr-fork": "0.0.5",
"uglify-js": "3.3.8",
"unique-number": "2.0.1"
"uglify-js": "3.3.8"
},
"engines": {
"node": ">= 8"

0 comments on commit 51e3f11

Please sign in to comment.