Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 10, 2024
1 parent fc45650 commit 005e34f
Show file tree
Hide file tree
Showing 21 changed files with 941 additions and 3 deletions.
87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,93 @@

> Package changelog.
<section class="release" id="unreleased">

## Unreleased (2024-09-10)

<section class="packages">

### Packages

<section class="package" id="string-base-unreleased">

#### [@stdlib/string/base](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base)

<details>

<section class="features">

##### Features

- [`095449b`](https://github.com/stdlib-js/stdlib/commit/095449bc5f6084b363a5b1dc1deb040fd029b76b) - add `atob` to namespace

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="string-base-atob-unreleased">

#### [@stdlib/string/base/atob](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/atob)

<details>

<section class="features">

##### Features

- [`37e0d70`](https://github.com/stdlib-js/stdlib/commit/37e0d70a86a621a109f74c68adbc6aa4a4177f0f) - add `string/base/atob`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

</section>

<!-- /.packages -->

<section class="contributors">

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:

- Athan Reines

</section>

<!-- /.contributors -->

<section class="commits">

### Commits

<details>

- [`095449b`](https://github.com/stdlib-js/stdlib/commit/095449bc5f6084b363a5b1dc1deb040fd029b76b) - **feat:** add `atob` to namespace _(by Athan Reines)_
- [`37e0d70`](https://github.com/stdlib-js/stdlib/commit/37e0d70a86a621a109f74c68adbc6aa4a4177f0f) - **feat:** add `string/base/atob` _(by Athan Reines)_

</details>

</section>

<!-- /.commits -->

</section>

<!-- /.release -->

<section class="release" id="v0.3.1">

## 0.3.1 (2024-08-18)
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
Frank Kovacs <fran70kk@gmail.com>
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
Gunj Joshi <gunjjoshi8372@gmail.com>
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
Harshita Kalani <harshitakalani02@gmail.com>
Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com>
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
James Gelok <jdgelok@gmail.com>
Jaysukh Makvana <jaysukhmakvana2004@gmail.com>
Jenish Thapa <141203631+jenish-thapa@users.noreply.github.com>
Jithin KS <jithinks112@gmail.com>
Joel Mathew Koshy <joelmathewkoshy@gmail.com>
Joey Reed <joeyrreed@gmail.com>
Expand Down Expand Up @@ -86,8 +88,10 @@ Stephannie Jiménez Gacha <steff456@hotmail.com>
Suraj kumar <125961509+kumarsuraj212003@users.noreply.github.com>
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com>
Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com>
Utkarsh <http://utkarsh11105@gmail.com>
Utkarsh Raj <rajutkarsh2505@gmail.com>
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
Varad Gupta <varadgupta21@gmail.com>
Xiaochuan Ye <tap91624@gmail.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
Expand All @@ -96,3 +100,4 @@ nishant-s7 <97207366+nishant-s7@users.noreply.github.com>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rainn <88160429+AmCodesLame@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
yaswanth <116426380+yaswanthkosuru@users.noreply.github.com>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/string.svg
[npm-url]: https://npmjs.org/package/@stdlib/string

[test-image]: https://github.com/stdlib-js/string/actions/workflows/test.yml/badge.svg?branch=v0.3.1
[test-url]: https://github.com/stdlib-js/string/actions/workflows/test.yml?query=branch:v0.3.1
[test-image]: https://github.com/stdlib-js/string/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/string/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/string?branch=main
Expand Down
110 changes: 110 additions & 0 deletions base/atob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!--
@license Apache-2.0
Copyright (c) 2024 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# atob

> Decode a string of data which has been encoded using Base64 encoding.
<!-- Package usage documentation. -->

<section class="usage">

## Usage

<!-- eslint-disable stdlib/no-redeclare -->

```javascript
var atob = require( '@stdlib/string/base/atob' );
```

#### atob( str )

Decodes a string of data which has been encoded using Base64 encoding.

<!-- eslint-disable stdlib/no-redeclare -->

```javascript
var out = atob( 'SGVsbG8sIHdvcmxk' );
// returns 'Hello, world'
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- This function differs from the global [`atob`][mdn-atob] available in web browsers and more recent Node.js versions in that the function returns `null` when provided a string containing non-ASCII characters, rather than raising an exception.

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint-disable stdlib/no-redeclare -->

```javascript
var atob = require( '@stdlib/string/base/atob' );

var str = 'SGVsbG8gV29ybGQh';
var out = atob( str );
// returns 'Hello World!'

str = 'SEVMTE8gV09STEQh';
out = atob( str );
// returns 'HELLO WORLD!'

str = 'VG8gYmUsIG9yIG5vdCB0byBiZTogdGhhdCBpcyB0aGUgcXVlc3Rpb24u';
out = atob( str );
// returns 'To be, or not to be: that is the question.'
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[mdn-atob]: https://developer.mozilla.org/en-US/docs/Web/API/Window/atob

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
55 changes: 55 additions & 0 deletions base/atob/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var atob = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare


// MAIN //

bench( pkg, function benchmark( b ) {
var values;
var out;
var i;

values = [
'beepboop',
'foobar',
'xyzabc'
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = atob( values[ i%values.length ] );
if ( typeof out !== 'string' ) {
b.fail( 'should return a string' );
}
}
b.toc();
if ( !isString( out ) ) {
b.fail( 'should return a string' );
}
b.pass( 'benchmark finished' );
b.end();
});
55 changes: 55 additions & 0 deletions base/atob/benchmark/benchmark.polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var atob = require( './../lib/polyfill.js' ); // eslint-disable-line stdlib/no-redeclare


// MAIN //

bench( pkg + '::polyfill', function benchmark( b ) {
var values;
var out;
var i;

values = [
'beepboop',
'foobar',
'xyzabc'
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = atob( values[ i%values.length ] );
if ( typeof out !== 'string' ) {
b.fail( 'should return a string' );
}
}
b.toc();
if ( !isString( out ) ) {
b.fail( 'should return a string' );
}
b.pass( 'benchmark finished' );
b.end();
});
22 changes: 22 additions & 0 deletions base/atob/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

{{alias}}( str )
Decodes a string of data which has been encoded using Base64 encoding.

Parameters
----------
str: string
Binary string containing base64-encoded data.

Returns
-------
out: string
An ASCII string containing decoded data.

Examples
--------
> var out = {{alias}}( 'SGVsbG8sIHdvcmxk' )
'Hello, world'

See Also
--------

Loading

0 comments on commit 005e34f

Please sign in to comment.