Comparing version 0.1.0 to 0.1.1
@@ -17,2 +17,10 @@ var os = require('os') | ||
if (!os.platform) { | ||
osShim.platform = platform | ||
} | ||
if (!os.arch) { | ||
osShim.arch = arch | ||
} | ||
if (!os.endianness) { | ||
@@ -46,2 +54,10 @@ osShim.endianness = endianness | ||
function platform() { | ||
return process.platform | ||
} | ||
function arch() { | ||
return process.arch | ||
} | ||
function endianness() { | ||
@@ -48,0 +64,0 @@ var isEndianness = ((new Uint32Array((new Uint8Array([1,2,3,4])).buffer))[0] === 0x04030201) |
{ | ||
"name": "os-shim", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Native OS module API shim for older node.js versions", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/adesisnetlife/node-os-shim", |
@@ -5,7 +5,7 @@ # Node OS shim [![Build Status](https://secure.travis-ci.org/AdesisNetlife/node-os-shim.png?branch=master)](http://travis-ci.org/AdesisNetlife/node-os-shim) | ||
## About | ||
## About | ||
Node.js team was frozen the [OS module API][1] in 0.10.x version, however the API differs a bit in lower node.js versions | ||
This shim just provides the missing OS module API that exist on the latest node.js versions. | ||
This shim just provides the missing OS module API that exist on the latest node.js versions. | ||
You can use it in lower node.js versions and feels like you are in latest versions | ||
@@ -44,2 +44,8 @@ | ||
#### os.platform() | ||
Returns the operating system platform | ||
#### os.arch() | ||
Returns the operating system CPU architecture | ||
## Contributing | ||
@@ -70,2 +76,4 @@ | ||
- **0.1.1** `2013-12-11` | ||
- Add platform() and arch() methods (for Node.js 0.4.x) | ||
- **0.1.0** `2013-12-11` | ||
@@ -76,2 +84,4 @@ - Initial release | ||
- Add `os.networkInterfaces()` shim method | ||
Do you miss something? Open an issue or make a PR! | ||
@@ -78,0 +88,0 @@ |
@@ -11,2 +11,4 @@ var expect = require('expect.js') | ||
var shimAPI = [ 'tmpdir', 'endianness', 'platform', 'arch', 'EOL' ] | ||
describe('os', function () { | ||
@@ -16,8 +18,6 @@ | ||
if (isNode10) { | ||
osCopy.tmpdir = os.tmpdir | ||
os.tmpdir = undefined | ||
osCopy.endianness = os.endianness | ||
os.endianness = undefined | ||
osCopy.EOL = os.EOL | ||
os.EOL = undefined | ||
shimAPI.forEach(function (prop) { | ||
osCopy[prop] = os[prop] | ||
os[prop] = undefined | ||
}) | ||
} | ||
@@ -33,5 +33,5 @@ }) | ||
// restore members references | ||
os.tmpdir = osCopy.tmpdir | ||
os.endiannessos = osCopy.endianness | ||
os.EOL = osCopy.EOL | ||
shimAPI.forEach(function (prop) { | ||
os[prop] = osCopy[prop] | ||
}) | ||
} | ||
@@ -111,4 +111,36 @@ }) | ||
describe('platform()', function () { | ||
it('should be expose the method', function () { | ||
expect(osShim.platform).to.be.a('function') | ||
}) | ||
it('should use the exposed shim method', function () { | ||
expect(osShim.platform).to.not.be.equal(os.platform) | ||
}) | ||
it('should return the proper EOL value', function () { | ||
expect(osShim.platform()).to.be.equal(process.platform) | ||
}) | ||
}) | ||
describe('arch()', function () { | ||
it('should be expose the method', function () { | ||
expect(osShim.arch).to.be.a('function') | ||
}) | ||
it('should use the exposed shim method', function () { | ||
expect(osShim.arch).to.not.be.equal(os.arch) | ||
}) | ||
it('should return the proper EOL value', function () { | ||
expect(osShim.arch()).to.be.equal(process.arch) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9249
164
97