node-stringbuilder
Advanced tools
+58
| 'use strict'; | ||
| const expect = require('chai').expect; | ||
| const StringBuilder = require('../index'); | ||
| describe('#append', function() { | ||
| it('should append text', function() { | ||
| var sb = StringBuilder.from('First'); | ||
| sb.append(', Second').append(', Third'); | ||
| var result = sb.toString(); | ||
| expect(result).to.equal('First, Second, Third'); | ||
| }); | ||
| it('should append text', function() { | ||
| var sb = StringBuilder.from(''); | ||
| sb.append('First').append(', Second').append(', Third'); | ||
| var result = sb.toString(); | ||
| expect(result).to.equal('First, Second, Third'); | ||
| }); | ||
| it('should append text and line, and finally trim the whitespace', function() { | ||
| var sb = StringBuilder.from(''); | ||
| sb.appendLine('First').appendLine('Second').appendLine('Third'); | ||
| var result = sb.trim().toString(); | ||
| expect(result).to.equal('First\nSecond\nThird'); | ||
| }); | ||
| it('should append text repeatedly, finally delete the last two characters', function() { | ||
| var sb = StringBuilder.from(''); | ||
| sb.appendRepeat('Three, ', 3).delete(-2); | ||
| var result = sb.trim().toString(); | ||
| expect(result).to.equal('Three, Three, Three'); | ||
| }); | ||
| }); | ||
| describe('#insert', function() { | ||
| it('should insert text at head', function() { | ||
| var sb = StringBuilder.from(', Second'); | ||
| sb.insert('First').append(', Third'); | ||
| var result = sb.toString(); | ||
| expect(result).to.equal('First, Second, Third'); | ||
| }); | ||
| it('should insert text at middle', function() { | ||
| var sb = StringBuilder.from('First'); | ||
| sb.append(', Third').insert(5, ', Second'); | ||
| var result = sb.toString(); | ||
| expect(result).to.equal('First, Second, Third'); | ||
| }); | ||
| it('should insert text at end', function() { | ||
| var sb = StringBuilder.from('First'); | ||
| sb.insert(sb.length(), ', Second').insert(sb.length(), ', Third'); | ||
| var result = sb.toString(); | ||
| expect(result).to.equal('First, Second, Third'); | ||
| }); | ||
| }); |
+2
-2
@@ -311,4 +311,4 @@ # We borrow heavily from the kernel build setup, though we are simpler since | ||
| quiet_cmd_regen_makefile = ACTION Regenerating $@ | ||
| cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/home/magiclen/npm/node-stringbuilder/build/config.gypi -I/usr/local/lib/node_modules/node-gyp/addon.gypi -I/home/magiclen/.node-gyp/8.6.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/magiclen/.node-gyp/8.6.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp" "-Dnode_lib_file=/home/magiclen/.node-gyp/8.6.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/magiclen/npm/node-stringbuilder" "-Dnode_engine=v8" binding.gyp | ||
| Makefile: $(srcdir)/../../.node-gyp/8.6.0/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../usr/local/lib/node_modules/node-gyp/addon.gypi | ||
| cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/home/magiclen/npm/node-stringbuilder/build/config.gypi -I/usr/local/lib/node_modules/node-gyp/addon.gypi -I/home/magiclen/.node-gyp/8.8.1/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/magiclen/.node-gyp/8.8.1" "-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp" "-Dnode_lib_file=/home/magiclen/.node-gyp/8.8.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/magiclen/npm/node-stringbuilder" "-Dnode_engine=v8" binding.gyp | ||
| Makefile: $(srcdir)/../../.node-gyp/8.8.1/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../usr/local/lib/node_modules/node-gyp/addon.gypi | ||
| $(call do_cmd,regen_makefile) | ||
@@ -315,0 +315,0 @@ |
@@ -38,6 +38,6 @@ # This file is generated by gyp; do not edit. | ||
| INCS_Debug := \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/include/node \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/src \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/deps/uv/include \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/deps/v8/include | ||
| -I/home/magiclen/.node-gyp/8.8.1/include/node \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/src \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/deps/uv/include \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/deps/v8/include | ||
@@ -74,6 +74,6 @@ DEFS_Release := \ | ||
| INCS_Release := \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/include/node \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/src \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/deps/uv/include \ | ||
| -I/home/magiclen/.node-gyp/8.6.0/deps/v8/include | ||
| -I/home/magiclen/.node-gyp/8.8.1/include/node \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/src \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/deps/uv/include \ | ||
| -I/home/magiclen/.node-gyp/8.8.1/deps/v8/include | ||
@@ -80,0 +80,0 @@ OBJS := \ |
+1
-1
| { | ||
| "name": "node-stringbuilder", | ||
| "version": "2.2.0", | ||
| "version": "2.2.1", | ||
| "description": "An easy and fast in-memory string builder for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-1
@@ -6,3 +6,3 @@ StringBuilder for Node.js | ||
| NOTICE: N-API is a new experimental feature in Node.js 8. Currently, it can be used by adding `--napi-modules` option when executing Node.js 8. | ||
| NOTICE: N-API is a new experimental feature in Node.js 8. | ||
@@ -9,0 +9,0 @@ ## Code Example |
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
112827
1.28%11
10%473
11.56%