8000 Auto-generated commit · stdlib-js/string-replace@b2e82d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b2e82d7

Browse files
committed
Auto-generated commit
1 parent ef6e7fc commit b2e82d7

File tree

2 files changed

+14
-138
lines changed

2 files changed

+14
-138
lines changed

.github/workflows/publish.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ jobs:
182182
fi
183183
# Trim leading and trailing whitespace:
184184
dep=$(echo "$dep" | xargs)
185-
version="^$(npm view $dep version)"
185+
version="$(npm view $dep version)"
186+
if [[ -z "$version" ]]; then
187+
continue
188+
fi
189+
version="^$version"
186190
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
187191
mv package.json.tmp package.json
188192
done
@@ -192,7 +196,11 @@ jobs:
192196
fi
193197
# Trim leading and trailing whitespace:
194198
dep=$(echo "$dep" | xargs)
195-
version="^$(npm view $dep version)"
199+
version="$(npm view $dep version)"
200+
if [[ -z "$version" ]]; then
201+
continue
202+
fi
203+
version="^$version"
196204
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
197205
mv package.json.tmp package.json
198206
done

test/dist/test.js

Lines changed: 4 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,145 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var replace = require( './../../dist' );
24+
var main = require( './../../dist' );
2525

2626

2727
// TESTS //
2828

29-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3030
t.ok( true, __filename );
31-
t.strictEqual( typeof replace, 'function', 'main export is a function' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
3232
t.end();
3333
});
34-
35-
tape( 'the function throws an error if the first argument is not a string', function test( t ) {
36-
var values;
37-
var i;
38-
39-
values = [
40-
5,
41-
null,
42-
true,
43-
false,
44-
void 0,
45-
NaN,
46-
[],
47-
{},
48-
function noop() {},
49-
/ /g
50-
];
51-
52-
for ( i = 0; i < values.length; i++ ) {
53-
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
54-
}
55-
t.end();
56-
57-
function badValue( value ) {
58-
return function badValue() {
59-
replace( value, '', '' );
60-
};
61-
}
62-
});
63-
64-
tape( 'the function throws an error if the second argument is not a string or regular expression', function test( t ) {
65-
var values;
66-
var i;
67-
68-
values = [
69-
5,
70-
null,
71-
true,
72-
false,
73-
void 0,
74-
NaN,
75-
[],
76-
{},
77-
function noop() {}
78-
];
79-
80-
for ( i = 0; i < values.length; i++ ) {
81-
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
82-
}
83-
t.end();
84-
85-
function badValue( value ) {
86-
return function badValue() {
87-
replace( 'string', value, '' );
88-
};
89-
}
90-
});
91-
92-
tape( 'the function throws an error if the third argument is not a function or string', function test( t ) {
93-
var values;
94-
var i;
95-
96-
values = [
97-
5,
98-
null,
99-
true,
100-
false,
101-
void 0,
102-
NaN,
103-
[],
104-
{}
105-
];
106-
107-
for ( i = 0; i < values.length; i++ ) {
108-
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
109-
}
110-
t.end();
111-
112-
function badValue( value ) {
113-
return function badValue() {
114-
replace( 'string', 'str', value );
115-
};
116-
}
117-
});
118-
119-
tape( 'the function replaces all occurrences of a string search value', function test( t ) {
120-
var out;
121-
122-
out = replace( 'abc abc abc', 'b', '' );
123-
t.equal( out, 'ac ac ac', 'returns expected value' );
124-
125-
out = replace( 'abc abc abc', 'b', 'cd' );
126-
t.equal( out, 'acdc acdc acdc', 'returns expected value' );
127-
128-
out = replace( 'Et tu, Brute?', 'Brute?', 'Caesar?' );
129-
t.equal( out, 'Et tu, Caesar?', 'returns expected value' );
130-
131-
t.end();
132-
});
133-
134-
tape( 'the function replaces matches of a regular expression', function test( t ) {
135-
var expected;
136-
var out;
137-
138-
out = replace( 'aBcDeFgHiJkLmNoPqRsTuVwXYZ', /[A-Z]+/, '' );
139-
expected = 'acDeFgHiJkLmNoPqRsTuVwXYZ';
140-
t.equal( out, expected, 'replaces letters matching the regular expression (first occurrence)' );
141-
142-
out = replace( 'aBcDeFgHiJkLmNoPqRsTuVwXYZ', /[A-Z]+/g, '' );
143-
expected = 'acegikmoqsuw';
144-
t.equal( out, expected, 'replaces letters matching the regular expression (global)' );
145-
146-
t.end();
147-
});
148-
149-
tape( 'the function replaces matches with values returned by a replacer function', function test( t ) {
150-
var expected;
151-
var out;
152-
var str;
153-
154-
str = 'Oranges and lemons say the bells of St. Clement\'s';
155-
out = replace( str, /([^\s]+)/gi, replacer );
156-
157-
expected = '/Oranges/ /and/ /lemons/ /say/ /the/ /bells/ /of/ /St./ /Clement\'s/';
158-
t.equal( out, expected, 'replaces matches using replacer function' );
159-
160-
t.end();
161-
162-
function replacer( match, p1 ) {
163-
return '/' + p1 + '/';
164-
}
165-
});

0 commit comments

Comments
 (0)
0