From 7dcdbcb5f259d05b9bd88f477efc2438cfd9ae54 Mon Sep 17 00:00:00 2001 From: HaidarJbeily7 Date: Sun, 24 Nov 2024 00:35:03 +0300 Subject: [PATCH] feat: implement dir walkjs --- eo2js-runtime/src/objects/org/eolang/fs/dir$walk.js | 6 ++---- eo2js-runtime/test/objects/org/eolang/fs/dir$walk.test.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/eo2js-runtime/src/objects/org/eolang/fs/dir$walk.js b/eo2js-runtime/src/objects/org/eolang/fs/dir$walk.js index bad7b3a..2ab1ae1 100644 --- a/eo2js-runtime/src/objects/org/eolang/fs/dir$walk.js +++ b/eo2js-runtime/src/objects/org/eolang/fs/dir$walk.js @@ -1,9 +1,7 @@ const object = require('../../../../runtime/object') const {LAMBDA} = require('../../../../runtime/attribute/specials'); const at_void = require('../../../../runtime/attribute/at-void'); -const at_string = require('../../../../runtime/attribute/at-string'); -const fs = require('fs'); -const path = require('path'); +const data = require('../../../../runtime/data'); const glob = require('glob'); /** @@ -16,7 +14,7 @@ const dir$walk = function() { obj.assets[LAMBDA] = function(_) { const pattern = obj.attrs['glob'].data; const files = glob.sync(pattern); - return at_string(files.join('\n')); + return data.toObject(files.join('\n')); } return obj } diff --git a/eo2js-runtime/test/objects/org/eolang/fs/dir$walk.test.js b/eo2js-runtime/test/objects/org/eolang/fs/dir$walk.test.js index 76585e8..bc75d0b 100644 --- a/eo2js-runtime/test/objects/org/eolang/fs/dir$walk.test.js +++ b/eo2js-runtime/test/objects/org/eolang/fs/dir$walk.test.js @@ -2,7 +2,7 @@ const assert = require('assert'); const dir$walk = require('../../../../../temp/objects/org/eolang/fs/dir$walk'); const {STRING} = require('../../../../../temp/runtime/types'); const dataized = require('../../../../../temp/runtime/dataized'); -const at_string = require('../../../../runtime/attribute/at-string'); +const data = require('../../../../../temp/runtime/data'); const fs = require('fs'); const path = require('path'); @@ -26,7 +26,7 @@ describe('dir$walk', function() { it('should find files matching glob pattern', function() { const walk = dir$walk(); - walk.attrs['glob'] = at_string(path.join(directory, '**/*.txt')); + walk.attrs['glob'] = data.toObject(path.join(directory, '**/*.txt')); const result = dataized(walk, STRING).split('\n').sort(); assert.deepEqual( result,