<commit_before>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
'use strict';

const Promise = require('promise');
const SocketClient = require('./SocketClient');
const SocketServer = require('./SocketServer');
const _ = require('underscore');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const tmpdir = require('os').tmpdir();
const {spawn} = require('child_process');

const CREATE_SERVER_TIMEOUT = 10000;

const SocketInterface = {
  getOrCreateSocketFor(options) {
    return new Promise((resolve, reject) => {
      const hash = crypto.createHash('md5');
      Object.keys(options).sort().forEach(key => {
        if (options[key] && typeof options[key] !== 'string') {
          hash.update(JSON.stringify(options[key]));
        } else {
          hash.update(options[key]);
        }
      });

      const sockPath = path.join(
        tmpdir,
        'react-packager-' + hash.digest('hex')
      );

      if (fs.existsSync(sockPath)) {
        resolve(SocketClient.create(sockPath));
        return;
      }

      const logPath = path.join(tmpdir, 'react-packager.log');

      const timeout = setTimeout(<commit_msg>[react-native] bump create server timeout<commit_after>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
'use strict';

const Promise = require('promise');
const SocketClient = require('./SocketClient');
const SocketServer = require('./SocketServer');
const _ = require('underscore');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const tmpdir = require('os').tmpdir();
const {spawn} = require('child_process');

const CREATE_SERVER_TIMEOUT = 30000;

const SocketInterface = {
  getOrCreateSocketFor(options) {
    return new Promise((resolve, reject) => {
      const hash = crypto.createHash('md5');
      Object.keys(options).sort().forEach(key => {
        if (options[key] && typeof options[key] !== 'string') {
          hash.update(JSON.stringify(options[key]));
        } else {
          hash.update(options[key]);
        }
      });

      const sockPath = path.join(
        tmpdir,
        'react-packager-' + hash.digest('hex')
      );

      if (fs.existsSync(sockPath)) {
        resolve(SocketClient.create(sockPath));
        return;
      }

      const logPath = path.join(tmpdir, 'react-packager.log');

      const timeout = setTimeout(
{'fraction_non_alphanumeric': 0.13846685082872928, 'fraction_numerical': 0.006906077348066298, 'mean_word_length': 3.3110119047619047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1883847', 'n_tokens_mistral': 839, 'n_tokens_neox': 803, 'n_words': 233}