<commit_before>import {
  cadesplugin,
  CADESCOM_HASH_ALGORITHM_CP_GOST_3411,
  CADESCOM_BASE64_TO_BINARY,
} from './constants';

/**
 * @function
 * @name digestValue
 * @description Method returns promise with checksum of data that
 * transmitted in the parameters
 * @param {string} hashedData - string for checksum calculating
 * @return {string} checksum of data
 */
const digestValue = (hashedData) => {
  return new Promise((resolve, reject) => {
    cadesplugin.async_spawn(function *(args) {
      try {
        const oHashedData = yield cadesplugin.CreateObjectAsync('CAdESCOM.HashedData');

        yield oHashedData.propset_Algorithm(CADESCOM_HASH_ALGORITHM_CP_GOST_3411);
        yield oHashedData.propset_DataEncoding(CADESCOM_BASE64_TO_BINARY);
        yield oHashedData.Hash(args[0]);

        const sHashValue = yield oHashedData.Value;

        args[1](sHashValue);
      } catch (err) {
        args[2](cadesplugin.getLastError(err));
      }
    }, hashedData, resolve, reject);
  });
};

export default digestValue;
<commit_msg>[UPDATED] refactoring of digestValue function<commit_after>import {
  CreateObjectAsync,
  CADESCOM_HASH_ALGORITHM_CP_GOST_3411,
  CADESCOM_BASE64_TO_BINARY,
} from './constants';

/**
 * @function
 * @name digestValue
 * @description Method returns promise with checksum of data that
 * transmitted in the parameters
 * @param {string} hashedData - string for checksum calculating
 * @return {string} checksum of data
 */
const digestValue = async (hashedData) => {
  const oHashedData = await CreateObjectAsync('CAdESCOM.HashedData');

  await oHashedData.propset_Algorithm(CADESCOM_HASH_ALGORITHM_CP_GOST_3411);
  await oHashedData.propset_DataEncoding(CADESCOM_BASE64_TO_BINARY);
  await oHashedData.Hash(hashedData);

  return oHashedData.Value;
};

export default digestValue;

{'fraction_non_alphanumeric': 0.09547190398254228, 'fraction_numerical': 0.014729950900163666, 'mean_word_length': 4.695652173913044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3995100', 'n_tokens_mistral': 630, 'n_tokens_neox': 604, 'n_words': 125}