<commit_before>"use strict";

var _ = require("lodash");

var aws = require("aws-sdk"),
    Promise = require("promise");

module.exports = function(option) {
    var s3 = option === null ? new aws.S3() : new aws.S3(option);
    var extend = {
        CopyObject: function (param) {
            function doCopyObject(ok, grr) {
                var cpReq = s3.copyObject(param)
                    .on("success", function(data) {
                        ok(param);
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                cpReq.send();
            }
            return new Promise(doCopyObject);
        },

        GetObject: function (param) {
            function doGetObject(ok, grr) {
                var getReq = s3.getObject(param)
                    .on("success", function(data) {
                        if (data.data.ContentType === "application/json") {
                            ok(JSON.parse(data.data.Body));
                        } else {
                            ok(data.data.Body);
                        }
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                setTimeout(getReq.abort.bind(getReq), 5 * 1000);
                getReq.send();
            }
            return new Promise(doGetObject);
        },

        PutObject: function(param) {
            function doPutObject(ok, grr) {
                var putReq = s3.putObject(param)
                    .on("success", function() {
                        ok(param);
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                setTimeout(putReq.abort.bind(putReq), 5 * 1000);
                putReq.send();
            }
            return new Promise(doPutObject);
        },

        DeleteObjects: function(param) {
            // best effort remove delete old video
            function doDeleteObjects(ok, grr) {
                var delReq = s3.deleteObjects(param)
                .on("success", function(data) {
                    ok(param);
                })
                .on("error", function(err) {
                    grr(err);
                });

                delReq.send(); // fire away;
            }
            return new Promise(doDeleteObjects);
        }
    };
    _.assign(s3, extend);
    return s3;
};
<commit_msg>UPDATE: PutObject and GetObject has timeout argument<commit_after>"use strict";

var _ = require("lodash");

var aws = require("aws-sdk"),
    Promise = require("promise");

module.exports = function(option) {
    var s3 = option === null ? new aws.S3() : new aws.S3(option);
    var extend = {
        CopyObject: function (param) {
            function doCopyObject(ok, grr) {
                var cpReq = s3.copyObject(param)
                    .on("success", function(data) {
                        ok(param);
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                cpReq.send();
            }
            return new Promise(doCopyObject);
        },

        GetObject: function(param, timeout) {
            function doGetObject(ok, grr) {
                var getReq = s3.getObject(param)
                    .on("success", function(data) {
                        if (data.data.ContentType === "application/json") {
                            ok(JSON.parse(data.data.Body));
                        } else {
                            ok(data.data.Body);
                        }
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                if (timeout !== undefined) {
                    setTimeout(getReq.abort.bind(getReq), timeout);
                }
                getReq.send();
            }
            return new Promise(doGetObject);
        },

        PutObject: function(param, timeout) {
            function doPutObject(ok, grr) {
                var putReq = s3.putObject(param)
                    .on("success", function() {
                        ok(param);
                    })
                    .on("error", function(err) {
                        grr(err);
                    });
                if (timeout !== undefined) {
                    setTimeout(putReq.abort.bind(putReq), timeout);
                }
                putReq.send();
            }
            return new Promise(doPutObject);
        },

        DeleteObjects: function(param) {
            // best effort remove delete old video
            function doDeleteObjects(ok, grr) {
                var delReq = s3.deleteObjects(param)
                .on("success", function(data) {
                    ok(param);
                })
                .on("error", function(err) {
                    grr(err);
                });

                delReq.send(); // fire away;
            }
            return new Promise(doDeleteObjects);
        }
    };
    _.assign(s3, extend);
    return s3;
};

{'fraction_non_alphanumeric': 0.11752219220378232, 'fraction_numerical': 0.005403319181783096, 'mean_word_length': 1.0551149881046789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5332052', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1265, 'n_words': 247}