pax_global_header00006660000000000000000000000064127164724360014526gustar00rootroot0000000000000052 comment=25810f469944326c761f9f6273268453734a8465 clone-stats-1.0.0/000077500000000000000000000000001271647243600137605ustar00rootroot00000000000000clone-stats-1.0.0/LICENSE.md000066400000000000000000000020751271647243600153700ustar00rootroot00000000000000## The MIT License (MIT) ## Copyright (c) 2014 Hugh Kennedy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. clone-stats-1.0.0/README.md000066400000000000000000000016421271647243600152420ustar00rootroot00000000000000# clone-stats [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/clone-stats&title=clone-stats&description=hughsk/clone-stats%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) # Safely clone node's [`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) instances without losing their class methods, i.e. `stat.isDirectory()` and co. ## Usage ## [![clone-stats](https://nodei.co/npm/clone-stats.png?mini=true)](https://nodei.co/npm/clone-stats) ### `copy = require('clone-stats')(stat)` ### Returns a clone of the original `fs.Stats` instance (`stat`). ## License ## MIT. See [LICENSE.md](http://github.com/hughsk/clone-stats/blob/master/LICENSE.md) for details. clone-stats-1.0.0/index.js000066400000000000000000000003441271647243600154260ustar00rootroot00000000000000var Stat = require('fs').Stats module.exports = cloneStats function cloneStats(stats) { var replacement = new Stat Object.keys(stats).forEach(function(key) { replacement[key] = stats[key] }) return replacement } clone-stats-1.0.0/package.json000066400000000000000000000013011271647243600162410ustar00rootroot00000000000000{ "name": "clone-stats", "description": "Safely clone node's fs.Stats instances without losing their class methods", "version": "1.0.0", "main": "index.js", "browser": "index.js", "dependencies": {}, "devDependencies": { "tape": "~2.3.2" }, "scripts": { "test": "node test" }, "author": "Hugh Kennedy (http://hughsk.io/)", "license": "MIT", "repository": { "type": "git", "url": "git://github.com/hughsk/clone-stats" }, "bugs": { "url": "https://github.com/hughsk/clone-stats/issues" }, "homepage": "https://github.com/hughsk/clone-stats", "keywords": [ "stats", "fs", "clone", "copy", "prototype" ] } clone-stats-1.0.0/test.js000066400000000000000000000013651271647243600153020ustar00rootroot00000000000000var test = require('tape') var clone = require('./') var fs = require('fs') test('file', function(t) { compare(t, fs.statSync(__filename)) t.end() }) test('directory', function(t) { compare(t, fs.statSync(__dirname)) t.end() }) function compare(t, stat) { var copy = clone(stat) t.deepEqual(stat, copy, 'clone has equal properties') t.ok(stat instanceof fs.Stats, 'original is an fs.Stat') t.ok(copy instanceof fs.Stats, 'copy is an fs.Stat') ;['isDirectory' , 'isFile' , 'isBlockDevice' , 'isCharacterDevice' , 'isSymbolicLink' , 'isFIFO' , 'isSocket' ].forEach(function(method) { t.equal( stat[method].call(stat) , copy[method].call(copy) , 'equal value for stat.' + method + '()' ) }) }